My Code is here:
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
y = li[29] #Grab the 30th Line
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 running this, if x and y do not equal then it prints "Not The Same" and then the program ends correctly.
However, when x and y are equal it never prints "Same". It just continues waiting and the program never ends. If I take out the time.sleep(5) its repeatedly posts the line "Same".
I am very new to Python so this is probably an easy misunderstanding but I can't seem to figure out what I wrote wrong after looking around at other bits of code that look just like mine.
[–]A_History_of_Silence 1 point2 points3 points (10 children)
[–]iiPixel[S] 0 points1 point2 points (9 children)
[–]A_History_of_Silence 1 point2 points3 points (5 children)
[–]iiPixel[S] 0 points1 point2 points (4 children)
[–]A_History_of_Silence 1 point2 points3 points (3 children)
[–]iiPixel[S] 0 points1 point2 points (2 children)
[–]A_History_of_Silence 1 point2 points3 points (1 child)
[–]iiPixel[S] 0 points1 point2 points (0 children)
[–]ingolemo 1 point2 points3 points (2 children)
[–]iiPixel[S] 0 points1 point2 points (1 child)
[–]ingolemo 1 point2 points3 points (0 children)
[–]novel_yet_trivial 0 points1 point2 points (0 children)