7/15 "An integer is rquired" Error


#1
def reverse(text):
  lst = list(text)
  for char in lst:
    lst.pop(char)
    lst.insert(0,char)
 
  return str1

I am not sure what is wrong with my code and why it is yielding an error message “An integer is required”


#2

if we look at the documentation:

https://docs.python.org/2/tutorial/datastructures.html

we see that pop() removes an item from a given index, char is not an index.

which is why pop raises a type error, to indicate wrong data type argument


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.