Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,310 members, 7,811,917 topics. Date: Sunday, 28 April 2024 at 11:36 PM

Help With This Python Problem - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Help With This Python Problem (1503 Views)

I Need HELP With This Python Problem / Please Help With This Python Code / Pls Help With Python Problem (2) (3) (4)

(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(m): 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)

Learning coding / Is Programming Meant Only For Computer Science Students? / Unrestricted Bulksms Via Sim Hosting Server. Send To Dnd Now | Simhostng

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.