# [ ] review and run example
# the list before append
sample_list = [1, 1, 2]
print("sample_list before: ", sample_list)
sample_list.append(3)
# the list after append
print("sample_list after: ", sample_list)
# [ ] review and run example
# append number to sample_list
print("sample_list start: ", sample_list)
sample_list.append(3)
print("sample_list added: ", sample_list)
# append again
sample_list.append(8)
print("sample_list added: ", sample_list)
# append again
sample_list.append(5)
print("sample_list added: ", sample_list)
# [ ] run this cell several times in a row
# [ ] run cell above, then run this cell again
# [ ] review and run example
mixed_types = [1, "cat"]
# append number
mixed_types.append(3)
print("mixed_types list: ", mixed_types)
# append string
mixed_types.append("turtle")
print("mixed_types list: ", mixed_types)
# Currency Values
# [ ] create a list of 3 or more currency denomination values, cur_values
# cur_values, contains values of coins and paper bills (.01, .05, etc.)
cur_values = [.05,.25,1.00]
# [ ] print the list
print(cur_values)
# [ ] append an item to the list and print the list
cur_values.append(5.00)
print(cur_values)
[0.05, 0.25, 1.0]
[0.05, 0.25, 1.0, 5.0]
# Currency Names
# [ ] create a list of 3 or more currency denomination NAMES, cur_names
# cur_names contains the NAMES of coins and paper bills (penny, etc.)
cur_names=["penny", "dollar", "quarter"]
# [ ] print the list
print(cur_names)
# [ ] append an item to the list and print the list
cur_names.append("dime")
print(cur_names)
['penny', 'dollar', 'quarter']
['penny', 'dollar', 'quarter', 'dime']
# [ ] append additional values to the Currency Names list using input()
cur_names.append(input("Enter a currency name"))
# [ ] print the appended list
print(cur_names)
['penny', 'dollar', 'quarter', 'dime', 'penny']
# [ ] complete the Birthday Survey task above
bday_survey=[]
while True:
bDay=input("What day of the month were you born?")
if bDay=="q":
print(bday_survey)
break
elif int (bDay) >=1 and int(bDay) <=31:
bday_survey.append(bDay)
else:
print("Invalid input!")
bDay=input("What day of the month were you born?")
Invalid input!
KeyboardInterrupt: Interrupted by user
# [ ] Fix the Error
three_numbers = [1, 1, 2]
print("an item in the list is: ", three_numbers[2])
an item in the list is: 2