I am working on an assignment and am absolutely stuck. I've been trying to figure it out for days but I'm a beginner and it feels like im just spinning my tires.
For the assignment I have to import a random number, and ask the user whether it is odd or even. Then based on the answer I have to have the program return whether it is correct or incorrect. However with this code I have pasted below I can't get it to execute my while loops at all.
def assign2PartA():
import random
strNumber = random.randrange(1,50)
answer = raw_input("Is '" + str(strNumber) + "' Odd or Even?")
while strNumber % 2 == 0:
if answer is "odd":
return "incorrect"
else:
return "correct"
while strNumber % 2 != 0:
if answer is "odd":
return "correct"
else:
return "incorrect"
Any help at all would be greatly appreciated. I just need some pointers to get me headed in the right direction as I have spent hours literally getting nowhere.