₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,141 members, 8,510,345 topics. Date: Friday, 30 October 2026 at 09:15 AM

Toggle theme

Help With This Python Problem - Programming - Nairaland

Nairaland Forum › Science/Technology › Programming › Help With This Python Problem (1635 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 Problem • Please Help With This Python Code • Pls Help With Python Problem • 2 • 3 • 4

Chaos Theory Launches Traffikator: Nigeria's First Social Traffic App On August • Bad Languages Require Ides • Greatest List Of Freely Available Programming Books