Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAbdulkadir Kollere
1,723 PointsIt looks like Task 1 is no longer passing
Is there anything missing related to task 1 here? Task one is just importing the random library. Any help will be appreciated
import random
start = 5
def even_odd(num):
# If % 2 is 0, the number is even.
# Since 0 is falsey, we have to invert it with not.
return not num % 2
while start = True:
number = random.randint(1,99)
if even_odd(number) == True:
print("{} is even").format(number)
else:
print("{} is odd").format(number)
start = start - 1
continue
1 Answer
Umesh Ravji
42,386 PointsHi Abdulkadir, if you have introduced a syntax error, sometimes you will get an error telling you a previous task isn't passing anymore.
Comments for the issues:
while start = True: # change this line to while start:
number = random.randint(1,99)
if even_odd(number) == True:
print("{} is even").format(number) # format is method of string
else:
print("{} is odd").format(number) # format is method of string
start = start - 1 # make sure this is inside while loop, as you have an infinite loop otherwise
continue # you have no need for a continue statement
With changes made:
while start:
number = random.randint(1,99)
if even_odd(number) == True:
print("{} is even".format(number))
else:
print("{} is odd".format(number))
start = start - 1
Abdulkadir Kollere
1,723 PointsAbdulkadir Kollere
1,723 PointsNoted. Thanks. The indentation is really giving me a tough time.