print ("Let's find the nth odd number. Please enter a postive integer: ") answer = raw_input() nth = int(answer)
while counter < nth: if odd % 2 == 0: print str(odd) + (" is even. It doesn't go on the list.") odd = odd + 1 print ("We have found ") + str(counter) +(" odd numbers. Let's keep going.")
elif odd % 2 != 0: print str(odd) + " is odd. It goes on the list." odds.append(odd) if len(odds) == int(nth): print ("The ") + str(nth) + ("th odd number is ") + str(odd) break else: print ("We have found ") + str(len(odds)) +(" odd numbers. Let's keep going.") odd = odd + 1 counter = counter + 1
no subject
#odds
# This script will calculate the nth odd number
odd = 0
counter = 0
odds = []
print ("Let's find the nth odd number. Please enter a postive integer: ")
answer = raw_input()
nth = int(answer)
while counter < nth:
if odd % 2 == 0:
print str(odd) + (" is even. It doesn't go on the list.")
odd = odd + 1
print ("We have found ") + str(counter) +(" odd numbers. Let's keep going.")
elif odd % 2 != 0:
print str(odd) + " is odd. It goes on the list."
odds.append(odd)
if len(odds) == int(nth):
print ("The ") + str(nth) + ("th odd number is ") + str(odd)
break
else:
print ("We have found ") + str(len(odds)) +(" odd numbers. Let's keep going.")
odd = odd + 1
counter = counter + 1