dimanche 4 octobre 2020

What is wrong in my code? I think my logic is correct but syntax error is throwing up

Read a string from user input. The string must contain multiple characters. Delete all the characters that are in even positions. Print the resulting string.

Hint: Use math operator %, the for loop, and the if statement.

s = str(input())
itr = len(s)
for i in range(0,itr):
  if i % 2 == 0:
    print (s[i])
  else:
    s.remove(s[i])

Aucun commentaire:

Enregistrer un commentaire