How the program works
Takes a string from the user
Deletes it if there is a period or comma inside that string
3.split() that string into a list named reshte.
Deletes the first item from the list.
It takes the items whose first name is written in capital letters with
for loopthen displays the results.
I want to print the items with the index number in the output but I can't.
The input I give to the program:
The Persian League is the largest sport event dedicated to the deprived areas of Iran. The Persian League promotes peace and friendship. This video was captured by one of our heroes who wishes peace.
my code:
bs = [',','.']
reshte = input()
for s in bs:
if s in reshte:
reshte = reshte.replace(s,'')
reshte = reshte.split()
b = reshte[0]
css = [reshte.remove(b) for k in reshte if b in reshte]
for f in reshte:
if f[0] == f[0].upper():
print(f)
This is the output of my code == wrong:
Persian
League
Iran
Persian
League
But I want the output to be as follows == right:
2:Persian
3:League
15:Iran
17:Persian
18:League
Please help me solve this problem