kg_p= input('Would you like to enter your weight in Kg or Pound?')
while kg_p !='KG' or 'POUND':
print('You entered a invalid answer')
kg_p= input('Would you like to enter your weight again in Kg or Pound?')
weight=input('Please enter your weight:')
while True:
try:
weight_1=int(weight)
except ValueError:
print('You must enter your weight in integer')
weight=input('Please enter your weight again:')
if kg_p== 'KG':
show_1= weight_1
show_2= weight_1*2.20462 #pound
print('You weight are',show_1,'kg and',show_2,'pounds')
else:
#kg_p== 'Pound'
show_1= weight_1
show_2= weight_1/2.20462 #kg
print('You weight are',show_2,'kg and',show_1,'pounds')
I tried to enter ‘KG’ or ‘POUND’, jupyter notebook still printing ‘ You entered invalid answer’ and while continue without break. May I know, what is the issues? Thank you
New contributor
Satoshi Satoshi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.