Problem in "reverse" exercise


def reverse(text):
    for x in range(len(P)):
    return rev

it gives a "list index out of range" error.

Also what is the difference between "list index out of range" and "list assignment index out of range" error


uhm.. this line:


rev is an empty list? i think you want to get the value from P. also, len() start counting at 1, strings/list are zero indexed based, so you might want to do -1

a list index out of range is when you try to access a list with a index which is out of range, list assignement is when you try to append a item to a list to a position which is out of range


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