3.1.6.9 LAB: Operating with lists - basics

an anonymous user · January 14, 2021 · Python
hatList = [1, 2, 3, 4, 5]  # This is an existing list of numbers hidden in the hat.

# Step 1: write a line of code that prompts the user
# to replace the middle number with an integer number entered by the user.

# Step 2: write a line of code here that removes the last element from the list.

# Step 3: write a line of code here that prints the length of the existing list.

print(hatList)

print ("Change the middle number with an integer")

#user_numbers = int(input())

hatList [2] = int(input())

print("New list content:", hatList)

del hatList [4]

print("Last list content:", hatList)

print("\nList's length:", len(hatList))

Comments

Please sign up or log in to contribute to the discussion.