Can someone help me made a code in py in which if you enter a string, it will return "e" in every even index of the string | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can someone help me made a code in py in which if you enter a string, it will return "e" in every even index of the string

Examples are these: "Holiday" -- "eoeieae" "return" -- "eeeuen" "abaca" -- "ebece" Though it may be simple to you guys, I am in beginner level and have a hard time figuring this one. I want to analyze the code you guys will send and maybe it will help me figuring further challenges. Thank you. Also, if you can provide me any challenges at beginner level esp iteration related challenge, I am grateful to accept it and answer by myself. Thank you again.

8th May 2020, 9:31 AM
Xander Christians
Xander Christians - avatar
2 Answers
+ 3
a="holiday" for i,j in enumerate(a): if i%2==0: a=a.replace(j,"e") print(a)
8th May 2020, 9:37 AM
Abhay
Abhay - avatar
+ 1
Thank you. I have a hard time analyzing iteration with many variables but I'll try my best.
8th May 2020, 9:53 AM
Xander Christians
Xander Christians - avatar