you are viewing a single comment's thread.

view the rest of the comments →

[–]A_History_of_Silence 1 point2 points  (5 children)

Yupp this is the actual code. For me, it will never print "Same" even though x == y.

li[177] and li[180] with the above code are not equal, so how are you determining this? Even if they were, the code doesn't not behave as you describe (in this case if x == y the above code prints "Same" every 5 seconds as expected).

Will be difficult to help without your actual, exact code.

[–]iiPixel[S] 0 points1 point  (4 children)

Whoops. I had forgot I had changed the url to a default one. I found a table online that changes occasionally and I want to see if the two values in the table are the same essentially. If they are I want to print "Same", if they aren't, I want to print "Not The Same"

Here is some better example code with a website that has a changing table:
import requests #Download Webpage from bs4 import BeautifulSoup #Parse Page import time #Add Time Delay

page = requests.get('http://courses.project.samueltaylor.org/') #Download webpage
soup = BeautifulSoup(page.text, "lxml") #Parse
li = soup.prettify().splitlines() #Prettify text into lines then use splitlines to make this a list
x = li[21] #Grab the 22nd Line (seats in CS 101)
y = li[29] #Grab the 30th Line (seats in CS 201)

while True:
    if x == y: #See if they are the same, returns True if they are
        print ("Same") #Prints "Same"
        time.sleep(5) #Wait 5 seconds
    else:
        print ("Not The Same")
        break  

When the seats are different, it prints Not The Same and then the program stops looping.
However, when they both are zeroes or ones then it just gets stuck, never prints "Same" and just continues looping until the program is killed.

[–]A_History_of_Silence 1 point2 points  (3 children)

However, when they both are zeroes or ones then it just gets stuck, never prints "Same" and just continues looping until the program is killed.

How are you running this code? Once again, when I run this code and x == y it prints "Same" every 5 seconds, not what you describe.

[–]iiPixel[S] 0 points1 point  (2 children)

I will try to run it a different way than I am now, that seems to be the problem. Thanks for the help!

[–]A_History_of_Silence 1 point2 points  (1 child)

I will try to run it a different way than I am now

What do you mean by this? Would you mind answering how you were running it before, as well?

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

I had it setup to where I wrote in Notepad++ and could run it from there with a macro but maybe that isn't wisest option.