Answer to Question #246813 in Python for Sitora

Question #246813
Scenario

There once was a hat. The hat contained no rabbit, but a list of five

numbers: 1, 2, 3, 4, and

Your task is to

• write a line of code that prompts the user to replace the middle

number in the list with an integer number entered by the user

write a line of code that removes the last element from the list

(Step 2)

• write a line of code that prints the length of the existing list (Step 31.

Ready for this challenge?
1
Expert's answer
2021-10-05T02:32:35-0400
hat = [1, 2, 3, 4, 5]


number = int(input())


hat[len(hat) // 2] = number


hat.pop(-1)


print(len(hat))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS