Professional Documents
Culture Documents
Comp8 HO4 2ndterm
Comp8 HO4 2ndterm
def remove():
sport = input(“Which sport do you want to remove? ")
sports.remove(sport)
print(sport, "has been removed. ")
def search():
sport = input(“Types the name of sport you want to search. ")
if sport in sports:
print(sport, "is in the list. ")
else:
print(sport, "is not in the list. ") Name:____________________
def display(): Open Google Chrome
end = len(sports)
for i in range(end): Go to online-python.com
print(i, sports[i])
Create your own Python program
### Main program using the following commands:
select =""
while select != "X": def
print("List Of Sports") append
print("Add: Add a sport. ")
print("Remove: Remove a sport. ") remove
print("Display: Check the sports. ") print
print("Search: Search a specific sport. ") input
print("Close: Close the program. ")
select = input("Select an option you want to do. ") int
if else
if select == "Add": for
add()
while
if select == "Remove":
remove()
if select == "Search":
search()
if select == "Display”:
display()
1
2