I wrote a length converter with python, here are the codes:
active = True
while active:
option = input('please choose:\na:centimetre to inch \nb:inch to centimetre:')
if option == "a":
centimetre = input('Please enter centimetre:')
centimetre= float (centimetre)
inch = centimetre / 2.54
print(str(centimetre) + ' centimetre equals' + str(inch) + ' inches')
elif option == "b":
inch = input('Please enter inch:')
inch = float ( inch )
centimetre = inch * 2.54
print(str(inch) + ' inch equals ' + str(centimetre) + ' centimetre')
else:
print("sorry you entered wrong option。please enter 'a'or'b': ")
continue
status = input('continue? yes/no :')
if status == 'no':
active = False
It's ok when these codes run with notepad++ and http://www.pythontutor.com/
but when I try to use pycharm, it got error:
line 6, in <module>
centimetre= float (centimetre)
ValueError: could not convert string to float:
not sure where is the problems. Has anyone met this issue?