Skip to main content

Printing the hourly temperature in python

 

Write a loop to print all elements in hourly_temperature. Seperate elements with a -> surrounded by spaces


Sample output for the given program with input: 90 92 94 95

90 -> 92 -> 94 -> 95



user_input= input()
hourly_temprature = user_input.split()

# iterate the hourly_temprature using for loop
for i in range(0, len(hourly_temprature)-1):
    print(hourly_temprature[i],"->", end=' ')

 # last element of hourly_temprature, follwed by space and then new line
print(hourly_temprature[-1]," ")
 print()

Hope this is helpful. Write back to me in case you need help with your python task. I generally reply back within 24 hours. You can connect with me on Whatsapp also: +918602715108

Comments