Skip to content

Instantly share code, notes, and snippets.

@wynand1004
Created December 4, 2017 01:34
Show Gist options
  • Save wynand1004/8fba0798508fba2ec628f1679a7c5100 to your computer and use it in GitHub Desktop.
Save wynand1004/8fba0798508fba2ec628f1679a7c5100 to your computer and use it in GitHub Desktop.
A simple introduction / practice exercise to learn a little about Python lists.
import os
os.system("clear")
print("""
__ ___
(_ |_ _ _ | _ _|
__)|_(_|| || (-|(
""")
# 1) Create a list called captains and add the following names to it:
# Archer, Kirk, Decker, Kirk, Picard, Janeway
# print the list
print("1)")
delay = input("Please press enter to continue. > ")
# 2) Add Sisko to the end of the list
# print the list
print("\n2)")
delay = input("Please press enter to continue. > ")
# 3) Insert Garrett after Kirk and before Picard
# print the list
print("\n3)")
delay = input("Please press enter to continue. > ")
# 4) Remove Decker from the list
# print the list
print("\n4)")
delay = input("Please press enter to continue. > ")
# 5) print how many captains are on the list - count Kirk twice.
print("\n5)")
delay = input("Please press enter to continue. > ")
# 6) Ask the user for the name of a captain.
# If the captain is on the list print "NAME is on the list."
# If not, print"NAME is not on the list."
print("\n6)")
delay = input("Please press enter to continue. > ")
# 7) print how many times Kirk is on the list.
print("\n7)")
delay = input("Please press enter to continue. > ")
# 8) print the index of Picard on the list
print("\n8)")
delay = input("Please press enter to continue. > ")
# 9) Sort the list in alphabetical order
# print the list
print("\n9)")
delay = input("Please press enter to continue. > ")
# 10) print the names one by one on a separate line like so:
# NAME is a Star Trek captain.
print("\n10)")
delay = input("Please press enter to continue. > ")
@CodeByLine
Copy link

Not sure if this is a pace for raves--but: this is a great exercise, with so many string methods on one Star Ship!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment