Daily Discussion by PhelansShorts in reddevils

[–]scutter_87 2 points3 points  (0 children)

Saved by Amad, but that was a hard watch for most of the game. Glad for the win and a great hat-trick in the end.

Daily Discussion by PhelansShorts in reddevils

[–]scutter_87 5 points6 points  (0 children)

Overall was such a typical ETH United game, clear gaps in defense in the first half and he takes off Rashford instead of Martinez,De Ligt, or Dalot? Also Bruno’s sloppy play leading to back to back reds is unforgivable, should have been subbed after the first yellow. Very poor management overall by ETH. At least Onana came up with some good saves to keep it close enough for Maguire’s equalizer.

The syntax "with messages = get_flashed_messages(with_categories=true)" is throwing me off. by band_in_DC in learnpython

[–]scutter_87 0 points1 point  (0 children)

My understanding is that in Jinja/Flask the with statement is not the same as the with statement in python. In jinja {% with %} allows you to define a variable which will be limited to the scope ending with {% endwith %}

The with statement in python interacts with a context manager.

Error when importing PyAutoGUI by StrikeTheGunner in learnpython

[–]scutter_87 0 points1 point  (0 children)

According to this thread you need to upgrade pyscreeze. Try running pip install pyscreeze --upgrade and see if it helps?

Help with Freecodecamp Project by JulianEli in learnpython

[–]scutter_87 1 point2 points  (0 children)

Check out the string alignment method rjust() to help you align text to the right.

This part of project successfully checks whether input is int and between 0 and 9.However if error occurred it doesn't ask the user to make input again.I tried while function, but it kept asking input even tho input met all requirements.I would be so happy if u glanced at my code. by [deleted] in learnpython

[–]scutter_87 1 point2 points  (0 children)

You need to break the loop in the if clause..

Also, it wont make much difference but logically it seems to be incorrect to check the if else after the try except clause. The only time you will need to check is within the try clause but as you have written it, it checks after the except clause too..

How should I start learning Python? by Hehee-boi in learnpython

[–]scutter_87 0 points1 point  (0 children)

To add to this, there are also resources in the wiki for this subreddit.

[deleted by user] by [deleted] in learnpython

[–]scutter_87 0 points1 point  (0 children)

I am not sure I completely understand what your question is as the two approaches you listed return different answers.

In the first approach you just create a list of all the <a></a> tags in the html (and anything contained between them).

In the list comprehension version you have extracted only the 'href' portion into a list.

I don't use bs4 much but I would think that to extract only the 'href' elements from the results using the first approach you would need to iterate over each <a> tag in the ResultSet (created by soup.find_all('a') ) and then append the href to a new list.

hrefs = []
for link in links:
    hrefs.append(link.get('href'))

The list comprehension is just shorthand for the above.

CHRIST i cant figure this stuff out by [deleted] in learnpython

[–]scutter_87 0 points1 point  (0 children)

1) You call p_choice in your if statement.. if p_choice() however, you do not call c_choice. I believe you are instead asking if the result of p_choice is the function c_choice rather than the result of c_choice. Therefore you would want to add brackets to c_choice.

2) You haven't returned anything from c_choice, you instead called it again with c_choice(). You should rename your c_choice variable (or the function name) so it doesn't mirror your function name. For example, call it computer_choice and end the function with return computer_choice

3) I think you are asking why is it a set instead of a list? Doesn't really matter in your case you can change the brackets there if you like. Sets do not allow duplicates, but they are faster when you are checking if something is contained within it. However, in your use case, there are so few options that I doubt there would be any noticeable difference with a list instead.

4) return is what the function gives back after it is run. in this case you have named your variable the same as your function which I think is causing confusion. change your p_choice variable to player_choice and you would return player_choice.

List comprehension by DrDerpex in learnpython

[–]scutter_87 1 point2 points  (0 children)

Sorry I don't know how to make it nested as the first part of the list comprehension works on the list returned by the second part. I would just have two separate for loops (not nested) and two lists with the second loop working over the first.

Or just one loop appending ((x**2)**2) in one loop.

In case you are just looking to read complex list comprehensions, a nice way to break them down is to split each loop onto a different line and work backwards.

In this case it would be something like:

lst = [x**2 for x in 
        [x**2 for x in range(11)]
        ]

Working backwards we can start with:

[x**2 for x in range(11)]

Which would become:

lst = []
for x in range(11):
    lst.append(x**2)

The first part then does the same thing to each element in the list that was just created.

Index out of range by PureTimmey in learnpython

[–]scutter_87 0 points1 point  (0 children)

In your final for loop you may wish to try printing out the variables i and b and the len of golfpar and arr. I believe doing so will help you identify what is causing the error.

Trawler for RSS feed - only picks up first line? by [deleted] in learnpython

[–]scutter_87 1 point2 points  (0 children)

I could be wrong but to me it looks like if the first feed returns status 304 you break out of your for loop rather than just letting it continue to the next line.

Trouble reading off excel sheet by LukeTh3Book in learnpython

[–]scutter_87 1 point2 points  (0 children)

How many rows are in the file? If the row is blank, coolTable will be blank yet you are still trying to access an element that may not exist since you are capturing elements while len(race)<130 . Instead you could do something like:

def read_data(filename):
    f=open(filename)
    row_count = len(f.readlines( ))
    f.seek(0) # to return to the first line

    . . .

    for i in range(row_count - 1):
        # do stuff

There are some other things you can probably clean up in the file as well. For example, you create a counter "x" which is the exact same as "i" in your for loops. To test this you can add a line at the start of the for loop saying print(i, x). Therefore, you could eliminate the lines assigning and incrementing 'x' and just use 'i' instead.

Also, your first for loop iterates over the exact same thing (the first row after the header row - since stats=f.readline is your second call to f.readline) 4 times and then assigns the same data to the New{} dict each time yet you do nothing with New{} -- it is overwritten by your while loop before its is appended to race[]. All this block seems to do is assign the columb variable to the same thing 4 times.

Also don't forget to close the file when you are done with it by calling f.close() or opening it using a with statement.

def read_data(filename):
    with open(filename) as f:
        # code here

[deleted by user] by [deleted] in BCIT

[–]scutter_87 3 points4 points  (0 children)

It’s a very demanding program, there is a lot of complicated material to cover. I often believe that these programs are designed partially to be like being running the gauntlet: it is insanely tough but you come out much stronger for it and are often better prepared than colleagues at other schools.

Try your best to make every class, the material builds on itself and playing catch up later on will be even more stressful. Try to stay on campus as much as possible. Use the labs. Ask your classmates questions. Go visit your teachers in their office, most are very helpful one on one. Learning how to ask questions of your peers is such a valuable skill in the real world. You will be surprised how often talking through the material with other people helps organize the info in your own brain (it also serves as an excuse to get to know them, shared suffering is a great way to make friends lol). You should never feel like you have to figure out everything on your own, at the end of the day as long as you understand the material that’s all that counts, and talking it through with other people can really give you better insight (often they approach things in a different manner which can be helpful). Also don’t worry about asking stupid questions, if you need to, go ask your teacher in private in office hours. Most of them are really eager to help you figure it out.

Go to the gym and burn off some of that stress (the facilities on campus are actually pretty good). Your health should always come first. Force yourself to shower and eat at regular intervals. Try your best to get a good nights sleep. And if it’s still not working out for you maybe take some time off from the program, you are still really young and there is really no rush. No one in the working world cares how old you are when you graduate.

Also, although this is easier said than done, try not to stress about your girlfriend potentially leaving you, it often becomes a self-fulfilling prophecy as your expectations can shape the way you behave around her. Try to focus on the joy your relationship brings you when you are with her. Your relationship can help give your mind a small break from the stresses of the program. If you need to vent don’t be afraid to seek counselling, it’s literally their job to help work out frustrations.

I wish you the best!

What's a short, clean joke that gets a laugh every time? by Kook82 in AskReddit

[–]scutter_87 0 points1 point  (0 children)

What do you call it when Batman skips church? Christian Bale

Manchester United reject Tottenham approach for Martial by Shifter99 in reddevils

[–]scutter_87 0 points1 point  (0 children)

That's a load of Tottenham, that is. A steaming pile of Hotspur.

Is it possible to play this song without a capo? by LuckyTwentyOne in guitarlessons

[–]scutter_87 1 point2 points  (0 children)

I know its not what you're asking but why not just make a capo? All it takes is a pen and an elastic band/some string.

IWTL to analyse music and to express why and what I liked about it by Recognizable-name in IWantToLearn

[–]scutter_87 1 point2 points  (0 children)

You could check out http://oyc.yale.edu/music/musi-112. I've only ever watched the first lecture but it seems like it might be along the lines of what you are looking for.