0

I have coded a temperature converter from Celsius to Fahrenheit. When I run the program from my desktop, it asks for my input then quickly closes when I pass an integer to it. Is there a way to keep it open to view the results?

user_input_celsius = input('Enter temp in Celsius ')

user_input_celsius = int(user_input_celsius)




celsius_values = []

celsius_values = celsius_values + [user_input_celsius]

fahrenheit_values = []



for celsius in celsius_values:

     fahrenheit = celsius * 1.8 + 32

     fahrenheit_values = fahrenheit_values + [fahrenheit]

print(fahrenheit_values, end ='')
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Hydra17
  • 103
  • 7

2 Answers2

0

You have some options:

Run the program from an already-open terminal. Open a command prompt and type:

python myscript.py

Add code to wait at the end of your script:

input()
Jota
  • 697
  • 10
  • 24
0

You can ask the user to input any value before closing This way the program will not close until you type something

# program.py

user_input_celsius = input('Enter temp in Celsius ')    
user_input_celsius = int(user_input_celsius)
celsius_values = []    
celsius_values = celsius_values + [user_input_celsius]    
fahrenheit_values = []
for celsius in celsius_values:
         fahrenheit = celsius * 1.8 + 32    
     fahrenheit_values = fahrenheit_values + [fahrenheit]    
print(fahrenheit_values, end ='')

input("Press enter to exit")
exit()
Amine Messaoudi
  • 2,141
  • 2
  • 20
  • 37