# [ ] create and populate list called days_of_week then print it
days_of_week = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
print(days_of_week)
['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
# [ ] after days_of_week is run above, print the days in the list at odd indexes 1,3,5
print(days_of_week[1])
print(days_of_week[3])
print(days_of_week[5])
Tuesday
Thursday
Saturday
# [ ] create and populate list called phone_letters then print it
phone_letters = [" ","","ABC","DEF","GHI","JKL","MNO","PQRS","TUV","WXYZ"]
print(phone_letters)
[' ', '', 'ABC', 'DEF', 'GHI', 'JKL', 'MNO', 'PQRS', 'TUV', 'WXYZ']
# [ ] create a variable: day, assign day to "Tuesday" using days_of_week[]
# [ ] print day variable
day = days_of_week[1]
print(day)
Tuesday
# PART 2
# [ ] assign day to days_of_week index = 5
# [ ] print day
days_of_week[5]=day
print(days_of_week)
['Monday', 'Tuesday', 'Wednesday', 'Tryday', 'Friday', 'Saturday', 'Saturday']
# [ ] Make up a new day! - append an 8th day of the week to days_of_week
# [ ] print days_of_week
days_of_week.append("Restday")
print(days_of_week)
['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', 'Restday']
# [ ] Make up another new day - insert a new day into the middle of days_of_week between Wed - Thurs
# [ ] print days_of_week
days_of_week.insert(4,"Tryday")
print(days_of_week)
['Monday', 'Tuesday', 'Wednesday', 'Tryday', 'Tryday', 'Friday', 'Saturday', 'Saturday']
# [ ] Extend the weekend - insert a day between Fri & Sat in the days_of_week list
# [ ] print days_of_week
days_of_week.insert(6,"Icecreamday")
print(days_of_week)
['Monday', 'Tuesday', 'Wednesday', 'Tryday', 'Thursday', 'Friday', 'Icecreamday', 'Saturday', 'Sunday', 'Restday']
# [ ] print days_of_week
# [ ] modified week is too long - pop() the last index of days_of_week & print .pop() value
# [ ] print days_of_week
print(days_of_week)
print(days_of_week.pop())
print(days_of_week)
['Monday', 'Tuesday', 'Wednesday', 'Tryday']
Tryday
['Monday', 'Tuesday', 'Wednesday']
# [ ] print days_of_week
# [ ] delete (del) the new day added to the middle of the week
# [ ] print days_of_week
print(days_of_week)
del days_of_week[4]
print(days_of_week)
['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Saturday', 'Sunday']
# [ ] print days_of_week
# [ ] programmers choice - pop() any day in days_of week & print .pop() value
# [ ] print days_of_week
print(days_of_week)
print(days_of_week.pop(3))
print(days_of_week)
['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Saturday', 'Sunday']
Thursday
['Monday', 'Tuesday', 'Wednesday', 'Saturday', 'Sunday']
# [ ] create let_to_num()
def let_to_num():
letter=input("Enter a letter, space, or nothing: ").upper()
key = 0
while key < 10:
if letter==" ":
return key
break
elif letter in phone_letters[key]:
return key
break
else:
key = key + 1
while key == 10:
return "Not Found"
break
print(let_to_num())
2
# [ ] Challenge: write the code for "reverse a string"
some_numbers =[1,2,3,4,5,6,7,8,9,11,22,33,44,55,66,77]
rev_list = []
print(some_numbers)
while some_numbers:
last = some_numbers.pop(0)
rev_list.insert(0,last)
#print("new list:", rev_list)
print("\nnew list:", rev_list)
[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77]
new list: [77, 66, 55, 44, 33, 22, 11, 9, 8, 7, 6, 5, 4, 3, 2, 1]