faqts : Computers : Programming : Languages : Python

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

4 of 4 people (100%) answered Yes
Recently 4 of 4 people (100%) answered Yes

Entry

If i have a simple film database, how can i allow a film to be removed by index?

Aug 2nd, 2006 13:44
Reed O'Brien, Antonis Chatzidakis,


What is a simple database? A flat file? and array? CSV?
As a list of dicts?
>>> moviDB = [mov1, mov2, mov3, mov4]
>>> for mov in moviDB:
	print mov['title'], mov['year']

Code 46 2003
The Last American Hobo 1967
Jabberwocky 1977
Riding the Rails 1997

# Delete the third entry 
>>> del moviDB[2]
>>> for mov in moviDB:
	print mov['title'], mov['year']
	
Code 46 2003
The Last American Hobo 1967
Riding the Rails 1997