flag True while flag choice input If you would like to convert to pres

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
flag = True
while flag:
choice = (input('If you would like to convert F to C, press C. If it is C to F, press F. '))
if choice.isdigit():
print('Invalid input!')
elif choice == ' ':
print('Invalid input')
else:
print('Print the number you wish to convert to ' + choice + '.')
flag = False
def farengeitToCelcium(farengeit):
celcium = (farengeit - 32) / 1.8
return round(celcium, 1)
def celciumToFarengeit(celcium):
farengeit = celcium * 1.8 + 32
return round(farengeit, 1)
if choice == 'F':
celcium = float(input())
print(celciumToFarengeit(celcium))
elif choice == 'C':
farengeit = float(input())
print(farengeitToCelcium(farengeit))
else:
print('Invalid input! Please choose F or C. ')