What's new

Help List and Tuples Python Code

PHC_Mikasa

Forum Guru
Elite
Create a program that asks the user for his birthday in the format "Date-Month-Year"

example: "You were born in January"


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 program that asks the user for their name, adds it to a predefined list of people, and then prints the updated list:

Python:
people = ["Alice", "Bob", "Charlie"]

# Ask the user for their name
name = input("Enter your name: ")

# Add the user's name to the list
people.append(name)

# Print the updated list
print("Updated list of people:", people)

When you run this program, it will prompt you to enter your name. After you enter your name and press Enter, it will add your name to the people list and print the updated list.

Note: In this example, the predefined list of people is ["Alice", "Bob", "Charlie"], but you can modify it to include any names you want.
 

Similar threads

Back
Top