₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,331,258 members, 8,449,453 topics. Date: Tuesday, 21 July 2026 at 07:21 PM

Toggle theme

Help With This Python Problem - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingHelp With This Python Problem (1623 Views)

1 Reply

Help With This Python Problem by Nobody: 8:49pm On Jul 26, 2012
This is the exercise:
.
Create a list that contains the names of 5 students of a class
( do not ask for input to do that, simply create the list)
print the list.
Ask the user to input one more name and append it to the list.
Print the list.
Ask the user to input a number.
Print the name that has that number as index.

Add "John Smith" and "Mary Miller" at the beginning of the list.
Print the list.
.
.
My code:
.
names= ['Michael Dow', 'Cynthia James', 'Jonathan Mills', 'Peter Parker', 'Sidney Lee']
.
print(names)
.
names2= input('Please enter one More Name: ')
.
names.append(names2)
.
print(names)
.
#i have a problem with this part- donno how to go about it{any help?}.
.
names.insert(0,John Smith)
.
names.insert(1,Mary Miller)
.
print(names)
.
.
I need HELP with the bolded..
Any ideas?
Any special function that i don't know about?
Re: Help With This Python Problem by Seun(mod): 9:01pm On Jul 26, 2012
number = input('Please enter an index')
print(names[index])
Re: Help With This Python Problem by Nobody: 8:53am On Jul 27, 2012
Seun:
number = input('Please enter an index')
print(names[index])
thanks man.
You're the best.
1 Reply

I Need HELP With This Python ProblemPlease Help With This Python CodePls Help With Python Problem234

Help Me Learn Cake PhpA Very Good Python Programmer Needed AsapPlease What Payment Gateway Is Taxify Using