He all is there a way to loop through a list in reverse?
for i,q in enumerate(list): would go through it from 0 to X but i want to cyce through from X to 0 instead.
Reverse list
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Re: Reverse list
or alternatively a way to add new items to the start of a list rather than the end would serve equally as well
- Ocelot
- Lemma-Class Veteran
- Posts: 2402
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Reverse list
https://docs.python.org/2/library/funct ... l#reversedis there a way to loop through a list in reverse?
Code: Select all
for i,j in reversed(enumerate(some_list)):
# Or, depending on what you want:
for i,j in enumerate(reversed(some_list)):
or alternatively a way to add new items to the start of a list
Code: Select all
foo = 9000
some_list.insert(0, foo)
# Or
some_list = [ foo ] + some_list
< < insert Rick Cook quote here > >
Re: Reverse list
Awesome thanks Ocelot. that will do nicely
Who is online
Users browsing this forum: Ahrefs [Bot], fufuffiero