Skip to content

Latest commit

 

History

History
58 lines (40 loc) · 1.03 KB

exercise_4.md

File metadata and controls

58 lines (40 loc) · 1.03 KB

Unit 4 Practice

Exercise 4 - Looping Strings

4.1

Using a for loop, ask the user for the name of three items (animals, colors, fruits, or whatever you'd like).

4.2

Loop through the user's list and with iteration, print both the item and all the letters in the item.

Enter an animal: lynx
Enter an animal: ocelot
Enter an animal: puma

lynx
l
y
n
x
ocelot
o
c
e
l
o
t
puma
p
u
m
a

4.3

Loop through the list.

Loop through the letters of each word.

Create a list of the characters that occur in the words. If a letter has already been added to the list, skip it.

Output

Enter an animal: lynx
Enter an animal: ocelot
Enter an animal: puma

Letters used:
['l', 'y', 'n', 'x', 'o', 'c', 'e', 't', 'p', 'u', 'm', 'a']

Exercise 4 solution