# [ ] 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[6])
# [ ] assign a string 5 or more letters long to the variable: street_name
# [ ] print the 1st, 3rd and 5th characters
street_name = "Bridged"
print(street_name[:5:2])
# [ ] 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, the second charachter should be "i", "o",or "u"')
if team_name[1]=="i":
print(team_name,'contains "i".')
elif team_name[1]=="o":
print(team_name,'contains "o".')
elif team_name[1]=="u":
print(team_name,'contains "u".')
else:
print("Why can't you follow instructions???")
# [ ] 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="Church"
print(street_name[-3:])
# [ ] create and assign string variable: first_name
first_name="Braeden"
# [ ] print the first and last letters of name
print(first_name[0]+first_name[-1])
# [ ] Review, Run, Fix the error using string index
shoe = "tennis"
# print the last letter
print(shoe[-1])
#parenthesis were changed to brackets.