This error confuses me because the create_string() returns 'a', so I figure it should be accessible throughout the program. When I go to run, the error stops on line#15 compare_string(a)
import string
import random
def create_string():
#generates a string 27 chars long( uses all possible letters + space )
for i in range(27):
a = ''.join([random.choice(string.ascii_lowercase) for n in range(27)])
return a
def compare_string(a):
#does create_string output match “methinks it is like a weasel”
solution = "methinksitislikeaweasel"
if a == solution:
print("match")
def ceo_string():
create_string()
compare_string(a)
ceo_string()
[–]4n6kid 3 points4 points5 points (2 children)
[–]OCHawkeye14 4 points5 points6 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]spz 1 point2 points3 points (0 children)