-
Notifications
You must be signed in to change notification settings - Fork 1
/
Python4.py
30 lines (24 loc) · 830 Bytes
/
Python4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#Used to make requests
import urllib.request
import re
r = r'[0-9]*$'
base_url = "http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing="
next_nothing = "12345"
#next_nothing = "8022"
previous_nothing=0
# range(start, stop, step)
for i in range(1, 400, 1):
x = urllib.request.urlopen(base_url + next_nothing)
response_nothing = x.read().decode("utf-8")
next_nothing = re.findall(r, response_nothing)[0]
if next_nothing.isdigit() != True:
print("STOP! {0}".format(response_nothing))
print("Your last nothing is: {0}".format(previous_nothing))
next_nothing = input("Enter your next nothing or 'exit' to quit: ")
if next_nothing == "exit":
print("Goodbye!")
break
else:
previous_nothing=next_nothing
print("Next nothing: {0} at index {1}".format(next_nothing, i))
#peak.html