# [ ] review and run example - note the first element is always index = 0
student_name = "Alton"
print(student_name[0], "<-- first character at index 0")
print(student_name[1])
print(student_name[2])
print(student_name[3])
print(student_name[4])
# [ ] review and run example
student_name = "Jin"
if student_name[0].lower() == "a":
print('Winner! Name starts with A:', student_name)
elif student_name[0].lower() == "j":
print('Winner! Name starts with J:', student_name)
else:
print('Not a match, try again tomorrow:', student_name)
# [ ] review and run ERROR example
# cannot index out of range
student_name = "Tobias"
print(student_name[5])
# [ ] assign a string 5 or more letters long to the variable: street_name
# [ ] print the 1st, 3rd and 5th characters
name = input('enter your name')
print(name[0])
print(name[2])
print(name[4])
# [ ] Create an input variable: team_name - ask that second letter = "i", "o", or "u"
# [ ] Test if team_name 2nd character = "i", "o", or "u" and print a message
# note: use if, elif and else
team_name = input("Enter a team name: ")
if team_name[1].lower() == "i":
print('Winner! Name 2nd letter starts with i:', team_name)
elif team_name[1].lower() == "o":
print('Winner! Name 2nd letter starts with o:', team_name)
elif team_name[1].lower() == "u":
print('Winner! Name 2nd letter starts with u:', team_name)
else:
print("try again")
# [ ] review and run example
student_name = "Joana"
# get last letter
end_letter = student_name[-1]
print(student_name,"ends with", "'" + end_letter + "'")
# [ ] review and run example
# get second to last letter
second_last_letter = student_name[-2]
print(student_name,"has 2nd to last letter of", "'" + second_last_letter + "'")
# [ ] review and run example
# you can get to the same letter with index counting + or -
print("for", student_name)
print("index 3 =", "'" + student_name[3] + "'")
print("index -2 =","'" + student_name[-2] + "'")
# [ ] assign a string 5 or more letters long to the variable: street_name
# [ ] print the last 3 characters of street_name
street_name = 'wildbrook'
print(street_name[6])
print(street_name[7])
print(street_name[-1])
# [ ] create and assign string variable: first_name
first_name = input('enter your first name: ')
# [ ] print the first and last letters of name
print(first_name[0])
print(first_name[-1])
# [ ] Review, Run, Fix the error using string index
shoe = "tennis"
# print the last letter
print(shoe[-1])