- #1
antoniacarol
- 1
- 0
- TL;DR Summary
- Creating a python code--need help terminating a while loop
Please help!
I am trying to create a Python program for an assignment that will convert Celsius to Fahrenheit and vice versa depending on the input from the user. The numeric conversion portion of the code is working, however, if the user inputs "exit" the while loop is supposed to terminate and output "Goodbye". Additionally, if the user inputs anything else (like a word) the program is supposed to output "I do not understand. Please try again.".
I have tried moving the exit statement before temp value, I have tried saying "if temp =="exit" " and these have all resulted with the same error.
Whenever I input "exit" there is a ValueError stating it cannot convert string to float: "exi".
Please see the code I have so far in the photo below:
I am trying to create a Python program for an assignment that will convert Celsius to Fahrenheit and vice versa depending on the input from the user. The numeric conversion portion of the code is working, however, if the user inputs "exit" the while loop is supposed to terminate and output "Goodbye". Additionally, if the user inputs anything else (like a word) the program is supposed to output "I do not understand. Please try again.".
I have tried moving the exit statement before temp value, I have tried saying "if temp =="exit" " and these have all resulted with the same error.
Whenever I input "exit" there is a ValueError stating it cannot convert string to float: "exi".
Please see the code I have so far in the photo below: