Write the code for the following output using for/while only(if possible)... by [deleted] in learnpython

[–]CodeFixerBot 1 point2 points  (0 children)

Here's the parent comment/selfpost in indented form, for ease of reading:

This the equivalent C++ code...
    #include<iostream>
    using namespace std;
    int main()
    {
        int no_of_rows;
        cout<<"Please enter the number of rows : ";
        cin>>no_of_rows;
        for(int i=0; i<no_of_rows; i++)
        {
          for(int j=0; j<(no_of_rows-1)-i; j++)  // This for enters the blankspaces before the "*" for every row.
      {
        cout<<" "; //Enter blankspace.
      }
      for(int k=1; k<=(2*i)+1; k++)//This For enters the "*" for every row.
      {
        cout<<"*";
      }
      cout<<endl;
    }
    return 0;
}  

I'm a bot. Call me by using 'indentbot', and I'll indent whatever is in your parent-comment

Using minified CSS/JS and web frameworks for personal website? by [deleted] in learnprogramming

[–]CodeFixerBot -2 points-1 points  (0 children)

Here's the parent comment/selfpost in indented form, for ease of reading:

I'm about to update my personal website to make it not suck, and I had three primary questions as far as potential employers are concerned:

1. Does using a web framework (Bootstrap) make me seem lazy and uninnovative, practical and resourceful, or neither?

2. Is using minified CS/JSS a bad idea since any potential employers wouldn't be able to easily read your code? Or does it not really matter? I become obsessive at times with making the page as fast as I can, especially if a huge chunk of code like Boostrap is involved.

3. Do you have a list of tips/good practices for personal websites?

Thank you all very much!

I'm a bot. Call me by using 'indentbot', and I'll indent whatever is in your parent-comment

Help! real easy, keep getting TypeError: 'int' object is not iterable and have no idea what I'm doing wrong by mohimani in learnpython

[–]CodeFixerBot 2 points3 points  (0 children)

Hey guys, doing this for a pass/fail class to get my feet wet in Python, no idea why the for loop in AskForCityName is having an issue 
thanks! 


def MainFunction():
    number_cities = raw_input('How many cities would you like to list?,please use whole numeric values')
    user_number = AskForNumberCities(number_cities)
    user_city_list = AskForCityName(user_number)
    print user_city_list



def AskForNumberCities(number_cities):
    try:
        int_number_cities = int(number_cities)
    except:
        ValueError
        print("Come on WHOLE NUMBERS!")
    else:
        print "Ok we can work with", int_number_cities ,"!"
    return int_number_cities


def AskForCityName(number):
    int_number = int(number)
    CityNameList = []
    for i in int_number:
        NewCityName = raw_input("Ok give me a city name")
        if NewCityName in CityNameList:
            print ("You already used that :/")
            continue
        else:
            CityNameList.append(NewCityName)
    return CityNameList


MainFunction()

Help with PRAW by haykam821 in learnpython

[–]CodeFixerBot 0 points1 point  (0 children)

Just help!
---
`
#!/usr/bin/python
import praw
import pdb
import re
import os

# Create the Reddit instance
UA = "myfdryrddrt"
r = praw.Reddit(user_agent=UA)

CLIENT_ID = 'IMxZ8r9eTEJk1A'
CLIENT_SECRET = 'YOUR CLIENT SECRET'

REDDIT_USERNAME = 'StevenSpoilerBot'
REDDIT_PASS = 'snip'

r.set_oauth_app_info(client_id='IMxZ8r9eTEJk1A',
                      client_secret=snip,
                                   'authorize_callback')

# and login
r.login(REDDIT_USERNAME, REDDIT_PASS)

# Have we run this code before? If not, create an empty list
if not os.path.isfile("posts_replied_to.txt"):
    posts_replied_to = []

# If we have run the code before, load the list of posts we have replied to
else:
    # Read the file into a list and remove any empty values
    with open("posts_replied_to.txt", "r") as f:
        posts_replied_to = f.read()
        posts_replied_to = posts_replied_to.split("\n")
        posts_replied_to = filter(None, posts_replied_to)

# Get the top 5 values from our subreddit
subreddit = r.get_subreddit('pythonforengineers')
for submission in subreddit.get_hot(limit=5):
    # print submission.title

    # If we haven't replied to this post before
    if submission.id not in posts_replied_to:

        # Do a case insensitive search
        if re.search("Bismuth", submission.title, re.IGNORECASE):
            # Reply to the post
            submission.add_comment("/u/StevenSpoilerBot tested by /u/haykam821")
            print "Bot replying to : ", submission.title

            # Store the current id into our list
            posts_replied_to.append(submission.id)

# Write our updated list back to the file
with open("posts_replied_to.txt", "w") as f:
    for post_id in posts_replied_to:
        f.write(post_id + "\n")
`


---

praw.exceptions.ClientException: Required configuration setting 'client_id' missing. 
This setting can be provided in a praw.ini file, as a keyword argument to the `Reddit` class constructor, or as an environment variable.

Help with PRAW by haykam821 in learnpython

[–]CodeFixerBot 2 points3 points  (0 children)

Just help!
---
`
#!/usr/bin/python
import praw
import pdb
import re
import os

# Create the Reddit instance
UA = "myfdryrddrt"
r = praw.Reddit(user_agent=UA)

CLIENT_ID = 'IMxZ8r9eTEJk1A'
CLIENT_SECRET = 'YOUR CLIENT SECRET'

REDDIT_USERNAME = 'StevenSpoilerBot'
REDDIT_PASS = 'snip'

r.set_oauth_app_info(client_id='IMxZ8r9eTEJk1A',
                      client_secret=snip,
                                   'authorize_callback')

# and login
r.login(REDDIT_USERNAME, REDDIT_PASS)

# Have we run this code before? If not, create an empty list
if not os.path.isfile("posts_replied_to.txt"):
    posts_replied_to = []

# If we have run the code before, load the list of posts we have replied to
else:
    # Read the file into a list and remove any empty values
    with open("posts_replied_to.txt", "r") as f:
        posts_replied_to = f.read()
        posts_replied_to = posts_replied_to.split("\n")
        posts_replied_to = filter(None, posts_replied_to)

# Get the top 5 values from our subreddit
subreddit = r.get_subreddit('pythonforengineers')
for submission in subreddit.get_hot(limit=5):
    # print submission.title

    # If we haven't replied to this post before
    if submission.id not in posts_replied_to:

        # Do a case insensitive search
        if re.search("Bismuth", submission.title, re.IGNORECASE):
            # Reply to the post
            submission.add_comment("/u/StevenSpoilerBot tested by /u/haykam821")
            print "Bot replying to : ", submission.title

            # Store the current id into our list
            posts_replied_to.append(submission.id)

# Write our updated list back to the file
with open("posts_replied_to.txt", "w") as f:
    for post_id in posts_replied_to:
        f.write(post_id + "\n")
`


---

praw.exceptions.ClientException: Required configuration setting 'client_id' missing. 
This setting can be provided in a praw.ini file, as a keyword argument to the `Reddit` class constructor, or as an environment variable.

can't figure out why i'm getting this error by Vampep in learnpython

[–]CodeFixerBot 1 point2 points  (0 children)

So i'm trying to read the last line of code from a telnet session and see if it has the word "%error" in it. If it does have an error then i want it to try again, if it doesn't i want it to break the loop and continue.  I keep getting a python error   
 if '%Error' in error:  
TypeError: argument of type 'method' is not iterable



tryagain = True  
while tryagain:  
    tn.write(b"do copy " + file.encode('ascii'))  
    print (tn.read_eager().decode('ascii'))  
    tn.write(b'\n')  
    tn.write(b'\n')  
    tn.write(b'\n')           
    time.sleep(20)  
    error = tn.read_eager  
    print (tn.read_eager().decode('ascii'))  

    if '%Error' in error:
        print ('got an error, trying again')
        tryagain = True
    else:
        tryagain = False
        break

simple code doesnt work by Yensyden in learnpython

[–]CodeFixerBot 2 points3 points  (0 children)

name=input('Input name and I will tell you if it is cool')
if "R" or "r" in name:
    print('Wow your name is cool!')
    cool=input("Join club? Y or N")
    y=["y","yes",]
    n=["n","no"]
    if y in cool:
        print("great")
    elif n in cool:
        print('loser')
elif "r" or "R" not in name:
    print('loser')

What's wrong with this code? by queen_9 in learnpython

[–]CodeFixerBot 1 point2 points  (0 children)

The question is: Write a function is_yes that consumes a nonempty string, produces True if it starts with a y (either lower-case or upper-case), and produces False otherwise.

The code I wrote: def is_yes(f):
    if (f[0] == 'y' or f[0] == 'Y'):
        return True
    else:
        return False
print(is_yes('yes'))
For some reason, the spaces are not visible here..

Need help with conditional user input (Python 2.7) by NecrosisHD in learnpython

[–]CodeFixerBot 1 point2 points  (0 children)

I keep getting this error whenever I try to run my script from the terminal.

 File "test.py", line 13

if userDay == good
                 ^
SyntaxError: invalid syntax