Question: I am nearly there with this code, but it keeps saying I need add'l at the end: SCENARIO: Have a loop to print all elements

I am nearly there with this code, but it keeps saying I need add'l at the end:

SCENARIO:

Have a loop to print all elements in hourly_temperature. Separate elements with a -> surrounded by spaces.

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

90 -> 92 -> 94 -> 95 

Note: 95 is followed by a space, then a newline.

MY CODE:

user_input = input()

hourly_temperature = user_input.split()

for i in range(len(hourly_temperature)):

if i==len(hourly_temperature)-1:

print(hourly_temperature[i],end=' ' )

else:

print(hourly_temperature[i],end=' -> ' )

I am nearly there with this code, but it keeps saying I

X Testing with input: '90 92 94 95 Output is nearly correct; but whitespace differs. See highlights below. Special character legend Your output 90 -> 92 -> 94 -> 95 Expected output 90 -> 92 -> 94 -> 95 X Testing with input: '-32 -35-42' Output is nearly correct; but whitespace differs. See highlights below. Special character legend Your output -32 -> -35 -> -42 Expected output -32 -> -35 -> -42

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!