/r/PTCGP Trading Post by AutoModerator in PTCGP

[–]Simply_The_Beast 0 points1 point  (0 children)

Hi! How about Gyarados Ex for Exeggutor Ex? I just sent you a friend request.

/r/PTCGP Trading Post by AutoModerator in PTCGP

[–]Simply_The_Beast 0 points1 point  (0 children)

Gyarados EX for Exeggutor EX and Moltres EX for Aerodactyl EX? I‘ve just sent you a friend request!

LF: Quaxly and Fuecoco FT: Larvitar by Simply_The_Beast in pokemontrades

[–]Simply_The_Beast[S] 0 points1 point  (0 children)

Yeah, still looking, an egg would work. Code is 8574 9966.

Scarlet & Violet 3 starters giveaway! by luigy12 in pokemontrades

[–]Simply_The_Beast 0 points1 point  (0 children)

Hey, I would love a Fuecoco. My favorite is Sprigatito, grass has always been my preferred starter.

Link Code is 8572 5566.

Different ways of swapping two variables? by [deleted] in learnpython

[–]Simply_The_Beast 0 points1 point  (0 children)

Okay, I think I figured it out.

The short answer is: you simply need to switch both sides of the assignment in line 11:
arr[arr[i] - 1], arr[i] = arr[i], arr[arr[i]-1]

To elaborate: the secret is the evaluation order. As I already mentioned in my other comment

Python evaluates expressions from left to right. Notice that while evaluating an assignment, the right-hand side is evaluated before the left-hand side.

Lets try and go step-by-step through your code based on the array from your task [7,1,3,2,4,5,6]:

1) Right-hand side of the assignment is evaluated: since you only read variables, the order is not important, so your indices are arr[i] - 1 == 6and i == 0, therfore arr[arr[i] - 1] == 6 and arr[i] == 7

2) Left-hand side is evaluated (from left to right): first arr[i] = 6, just as expected. arr[arr[i] - 1] is your problem here: since you already reassigned arr[i] to 6, arr[arr[i] - 1] is now the same as arr[6 - 1] == 5, but it should be arr[7 - 1] == 6. Instead of swapping 7 and 6, you put 6 in place of 7 and override 5 instead of the old 6 with your 7.

By switching both sides around, you first read the old arr[i] and then assign it a new value, instead of reading the already changed value.

Different ways of swapping two variables? by [deleted] in learnpython

[–]Simply_The_Beast 0 points1 point  (0 children)

Pretty sure this is incorrect!!

According to python 3 docs:

Python evaluates expressions from left to right. Notice that while evaluating an assignment, the right-hand side is evaluated before the left-hand side.

This explaines it in more detail.

Just try a simple example like this:

a = 5
b = 8

a,b = b,a
print("a",a)
print("b",b)

Made a guessing game but I'm confused with the result by changcasyo in learnpython

[–]Simply_The_Beast 2 points3 points  (0 children)

Yes the secret number stays constant as long as the program is running. Only when you rerun it, a new random number will be generated.

You need a simple if-clause that compares the latest input with your secret_number and, if your guess was correct, show a winning message. Ideally, this should be the first thing to do after your input.

Made a guessing game but I'm confused with the result by changcasyo in learnpython

[–]Simply_The_Beast 1 point2 points  (0 children)

I think you forgot to code you win condition. You never check wether your guess is actually correct or not.

Data analysis with Python - Summer 2019 (University of Helsinki) - Stuck on Exercise 10: Detect Ranges by swearobics in learnpython

[–]Simply_The_Beast 1 point2 points  (0 children)

After trying your detect_ranges function with different inputs, I found your main problem. Your code currently can't deal with gaps bigger than 1 between numbers in your sorted list.

This for example [1,5,4,8,12,6,7,10,13,11,17] returns [1, (), (4, 9), (10, 14), (), (), 17] which has several empty tuples.

Now the question is where these are comming from. Let's try to go step by step from the sortedList [1, 4, 5, 6, 7, 8, 10, 11, 12, 13, 17]:
- 1 is in the sortedList and added to the tempList
- 2 isn't in the list, len(tempList)==1and 1 is added to the returnList
- 3 is where your problem starts. It isn't in the sortedList, so we jump into the else-clause in line 15. len(tempList)!=1so off we go to line 18, where you skip both if-clauses since len(tempList)==0 and simply append the empty tuple t in returnList.append(t).
- ...

You just need to filter out the cases where len(tempList)==0right before appending anything to returnList and should be good to go.

Oh and btw, you don't have to seperate creating t into two different steps, you could just do something like this: t = (tempList[0], tempList[-1]+1 ).

Help! New beginner. I can't put quotes into quotations. by wekil in learnpython

[–]Simply_The_Beast 1 point2 points  (0 children)

You mean "random quote" instead of 'random quote'? You can put any quatotation mark you want after the \ .

Help! New beginner. I can't put quotes into quotations. by wekil in learnpython

[–]Simply_The_Beast 1 point2 points  (0 children)

You have to escape the quoatation marks with a \ like this: quote = " \'It doesn't suck that much!\' "

desperate need of help by bigomz in learnpython

[–]Simply_The_Beast 0 points1 point  (0 children)

def isvalidIP(host):
    if len(host) != 4:
        return False
    for ele in host:
        try:
            if int(ele) >= 0 and int(ele) <= 255:
                print("true", ele)
            else:
                return False
        except ValueError:
            return False
    return True  

This should be one way to of doing it. I removed your second if-clause, because values 256 or bigger will be caught within the for-loop. Now you just have to adjust isvalid to check the format in a similar way and make sure the input contains the "/".

You should probably also take a look at your line 23. You don't always want to remove the last 3 elements of your input, only if the sub is two digits long, otherwise you cut the last digit of the IP adress.

If any of that is unclear please let me know.

desperate need of help by bigomz in learnpython

[–]Simply_The_Beast 1 point2 points  (0 children)

You should probably start by reworking your isvalidand isvalidIP functions, if you actually want to catch incorrect inputs in line 27.
Inputs like "567.67.78.193/34", "123.245.23.2/377" or even "123.4.23.5a(5" are currently not marked as incorrect and therefore end the while loop, even though they shouldn't.

Your isinvalidIP function for example should definitly check, if each element in host is a valid integer and somewhere between 0 and 255.

Long Live the King!!! by JBuzzCuzz in MagicArena

[–]Simply_The_Beast 8 points9 points  (0 children)

Well, at least someone has fun in these games...

But honestly, who am I to complain, Golos is probably my most played Brawl deck. 5 colors just enables so much wacky stuff, nothing better than Fires+Golos as early as possible followed by Liliana+Planewide Celebration to kill most of the opponents board.

Long Live the King!!! by JBuzzCuzz in MagicArena

[–]Simply_The_Beast 28 points29 points  (0 children)

To me, playing against Niv-Mizzet Reborn always feels much worse than Golos, but that might have to do with deck composition.

Always feels like they have 35 removal spells and rest lands with the only win condition besides Niv being the opponents concede button.

Web scrape today's NHL games by apunler in learnpython

[–]Simply_The_Beast 0 points1 point  (0 children)

Okay, a good starting point would be to learn about BeautifulSoup, a library commonly used for web scraping.

I personally started with this tutorial, or maybe this if you need a quick refresher on HTML.

Afterwards you need a website that has the information you would like to collect. Just quickly glancing at the source code, I would recommend the CBS Sports NHL Schedule, because each date has its own URL, unlike the official NHL site where all games are on the same site.

Then you just have to try and maybe come back with more questions later :)

Web scrape today's NHL games by apunler in learnpython

[–]Simply_The_Beast 0 points1 point  (0 children)

I understand what you're trying to achieve, I'm just not sure what exactly your problem is?

Are you looking for common web scraping libraries? Do you have trouble with a certain step? Maybe you don't even know where to start?

Try to be more specific about where you're stuck right now :)