0
def reverse(num):
  digits = []
  leng = num.count
  num1 = int(num)
  n = 0
  while(n < leng):
    last = num1 % 10
    num1 = (num1 - last) / 10
    last = str(last)
    digits = digits.append(last)
    n = n + 1

When I run this block it gives an error on the line with the while loop, saying < is not valid between an 'int' and 'builtin_function_or_method'. How do I save leng as an int?

1 Answers1

0

Well, according to shahkalpesh if you are trying to find length, you may use len(str(num)) if you are passing a int.

The count() method is avaible for string string.count(value). For string count() method returns the number of times a specified value appears in the string as documentation tells: count() for string in python.

The count() method is also avaible for list list.count(value) as documentation tells: count() for list in python

So you have an error because you try to use the < operator between an integer and an object that not is an integer (or superior numeric class).