0

I have an assignment in my computer science class that says "Create a program that asks the user to input a number between 20 and 99. The program must then print out the number in English words. If the user does not enter a value between 20 and 99 display an error message stating that the input is not within a valid range."

This is what I currently have in python. Please be nice, I have no programming experience what so ever!

a=int(eval(input('Pick a number between 20 through 99:')))
b=a//10
c=a%10
if a<20 and a>99:
    print('Error, enter number between 20 and 99')
elif b==2:
    print('The number is Twenty',end=' ')
elif b==3:
    print('The number is Thirty',end=' ')
elif b==4:
    print('The number is Fourty',end=' ')
elif b==5:
    print('The number is Fifty',end=' ')
elif b==6:
    print('The number is Sixty',end=' ')
elif b==7:
    print('The number is Seventy',end=' ')
elif b==8:
    print('The number is Eighty',end=' ')
elif b==9:
    print('The number is Ninety',end=' ')
if c==1:
    print('One')
elif c==2:
    print('Two')
elif c==3:
    print('Three')
elif c==4:
    print('Four')
elif c==5:
    print('Five')
elif c==6:
    print('Six')
elif c==7:
    print('Seven')
elif c==8:
    print('Eight')
else:
    print('Nine')
auth private
  • 1,318
  • 1
  • 9
  • 22
Austin Eiter
  • 3
  • 1
  • 2

0 Answers0