-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop_through_names.py
More file actions
56 lines (48 loc) · 1.16 KB
/
Copy pathloop_through_names.py
File metadata and controls
56 lines (48 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
names = [
"Naruto Uzumaki",
"Sasuke Uchiha",
"Sakura Haruno",
"Goku",
"Vegeta",
"Monkey D. Luffy",
"Zoro Roronoa",
"Nami",
"Edward Elric",
"Alphonse Elric",
"Light Yagami",
"L Lawliet",
"Mikasa Ackerman",
"Eren Yeager",
"Levi Ackerman",
"Tanjiro Kamado",
"Nezuko Kamado",
"Ichigo Kurosaki",
"Rukia Kuchiki",
"Killua Zoldyck",
"Gon Freecss",
"Saitama",
"Genos",
"Kaneki Ken",
"Todoroki Shoto",
"Midoriya Izuku",
"All Might",
"Erza Scarlet",
"Natsu Dragneel",
"Jiraiya"
]
for name in names:
print ("Hello",name)
for idx, name in enumerate(names,1):
print (f"{idx}.{name}") # Uses an f-string to format the output.
# Prints two spaces (for indentation), then the index number idx, a period ., a space, and then the option text.
#another way to do indexing without enumerate
index = 1 # Start counting at 1
for name in names:
print(f" {index}.. {name}")
index += 1 # Increase index by 1 each time
#count
count = 0
for name in names:
if "Naruto" in name:
count += 1
print(count)