Write a program that creates an array called temperatures and then add five temperatures input from the keyboard.
Print the array.
Sample Run:
Enter a temperature: 45
Enter a temperature: 67
Enter a temperature: 89
Enter a temperature: 47
Enter a temperature: 89
[45, 67, 89, 47, 89]
1
Expert's answer
2019-11-15T10:43:43-0500
temperatures = []
i = 0
while i < 5:
try:
t = int(input('Enter a temperature: '))
temperatures.append(t)
i += 1
except ValueError:
print('Enter a number')
print(temperatures)
Comments
Leave a comment