06 Feb PMCA Saturday 18:30 Python Homework 20.02.01.
Posted at 18:38h in Uncategorized 0 Comments
Write a program to ask the user for five names. The program should store the names in a list, and print them all out at the end. It should look something like this:
Enter 5 names:
The names are Tony, Paul, Nick, Michel, Kevin
- You can use for loop repeat 5 times to ask names
- You could use list.append() to add name into the list, for example:
>>> nameslist = 
>>> name = input()
- For better display result, you can use separator.join(list) to convert a list into one string, each item will be separated by the separator, for example:
>>> nameslist = [‘Sam’,’Kevin’,’Joe’]
>>> str_name = “, “.join(nameslist)
(after this str_name would be ‘Sam, Kevin, Joe‘)
Modify the program from question #1 to display only the third name the user typed in, like this:
The third name you entered is: Nick
Sorry, the comment form is closed at this time.