Reverse a string, in Python



Hello everyone. In reverse section I typed some code but it isn’t working and also there is no error. Here is the code:

def reverse(text):
  a = []
  count = len(text)
  while count > 0:
    count -= 1
  return "".join(a)

By the way it is working ubuntu terminal.


define isn’t working?

Remember that if you want to see the function in action, you need to call the function (functions only execute when called)


By saying working actually I want to say the system is not accepting it as a correct answer. When I try to print something, it does not work on the website but it is working on terminal.


i ran your code, and its accepting. Weird, maybe refresh the page. And there are no error messages of any kind? Can i see a screenshot of the full page


I tried refreshing and I tried it many times but it didn’t work then. However, the same code just worked out now. It is really weird… Whatever, thanks for your help :slight_smile: