❓ Help List Python Code

PHC-kT

Elite
1. Create a program with a predefined list of people. Ask the user for his name, add it to the end of the list and print the updated list
 
Sure! Here's a Python program that asks the user for their name, adds it to a predefined list, and then prints the updated list:

Python:
people = ['John', 'Mary', 'David']

name = input("Enter your name: ")
people.append(name)

print("Updated list of people:", people)

When you run this program, it will prompt you to enter your name. Once you enter your name, it will be added to the end of the people list, and then it will print the updated list of people.

For example, if you run the program and enter "Alice" as your name, the output will be:
Code:
Updated list of people: ['John', 'Mary', 'David', 'Alice']

Hope this helps! Let me know if you have any further questions.
 

About this Thread

  • 1
    Replies
  • 327
    Views
  • 1
    Participants
Last reply from:
Unknown user

Trending Topics

Online now

Members online
1,123
Guests online
2,220
Total visitors
3,343

Forum statistics

Threads
2,292,443
Posts
29,077,126
Members
1,209,356
Latest member
3r_thg
Back
Top