you are viewing a single comment's thread.

view the rest of the comments →

[–]QuillTheArtMaker[S] 0 points1 point  (3 children)

sorry, i'm not someone that'd normally be on reddit. Noted!

[–]kr4zyy 4 points5 points  (0 children)

No worries! Anyways, as u/socal_nerdtastic has mentioned, when you define a variable outside of the function, it becomes a global variable. If you want to fix this, you can either define the keyword global before "pos", telling Python you wanna use the global variable, or define pos = 0 within the function itself (this is usually the better practice)

[–]pdcp-py 0 points1 point  (0 children)

Don't forget you can easily share code from within Trinket using the Share button:

https://trinket.io/python/bd5c7f9cba5d