# [ ] review and run example
word = "cello"
for letter in word:
print(letter)
# [ ] review and run example
# note: the variable 'letter' changed to 'item'
word = "trumpet"
for item in word:
print(item)
# [ ] review and run example
# note: variable is now 'xyz'
# using 'xyz', 'item' or 'letter' are all the same result
word = "piano"
for xyz in word:
print(xyz)
# [ ] review and run example
# creates a new string (new_name) adding a letter (ltr) each loop
# Q?: how many times will the loop run?
student_name = "Skye"
new_name = ""
for ltr in student_name:
if ltr.lower() == "y":
new_name += ltr.upper()
else:
new_name += ltr
print(student_name,"to",new_name)
# [ ] Get user input for first_name
# [ ] iterate through letters in first_name
# - print each letter on a new line
first_name = input("enter your first name").title()
for character in first_name:
print(character)
# [ ] Create capitalize-io
first_name = input("enter your first name").title()
new_name = ''
for character in first_name:
if character.lower() == "i":
new_name += character.upper()
elif character.lower() == "o":
new_name += character.upper()
else:
new_name += character
print(new_name)
# [ ] review and run example
student_name = "Skye"
for letter in student_name[:3]:
print(letter)
# Iterate BACKWARDS
# [ ] review and run example
student_name = "Skye"
# start at "y" (student_name[2]), iterate backwards
for letter in student_name[2::-1]:
print(letter)
# [ ] create & print a variable, other_word, made of every other letter in long_word
long_word = "juxtaposition"
other_word = long_word[:]
print(other_word)
# Mirror Color
# [ ] get user input, fav_color
# [ ] print fav_color backwards + fav_color
# example: "Red" prints "deRRed"
fav_color = input("what is your favorite color?").lower()
print(fav_color[::-1] + fav_color)