+ 1
How do you use the reverse function
It's been giving me a hard time
2 odpowiedzi
+ 1
reverse is a method of list, that works in-place, which means it modify the list directly:
x = list(range(5))
print(x)
x.reverse()
print(x)
+ 2
This is as good an explanation as anything:
https://www.tutorialspoint.com/JUMP_LINK__&&__python__&&__JUMP_LINK/list_reverse.htm
If you're confused by why a specific Python script involving reverse doesn't work, share that and say what you expect it to do. Then I/we can explain why it doesn't work like that. It is hard to understand your specific confusion when you aren't more specific than reverse is giving you a hard time.