Python Forum
[xbmc] How to block the code from executed twice under the loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[xbmc] How to block the code from executed twice under the loop
#26
Instead of "print(some_list)", try "for item in some_list: print(item)". Or perhaps "print('\n'.join(some_list))".

And now that that question is answered, here's a few tips on making that small snippet better:
1) Instead of "some_list = list()", try "some_list = []"
2) Instead of "for ndx in range(len(some_list)):", try "for item in some_list:"
3) Instead of "some_list = list(); some_list.append(some_thing)", try "some_list = [some_thing]"

Small little improvements to readability would go miles to helping other people quickly see what's going on in your code.
Reply


Messages In This Thread
RE: [xbmc] How to block the code from executed twice under the loop - by nilamo - Oct-25-2016, 10:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] messagebox is not being executed please help erwinsiuda 2 2,329 Apr-02-2020, 01:56 AM
Last Post: Larz60+
  [Tkinter] Window unresponsive when executed. fawazcode 2 3,828 Sep-11-2017, 12:29 AM
Last Post: Larz60+
  [WxPython] Which def is executed? merlem 10 7,920 Feb-10-2017, 11:28 AM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020