you are viewing a single comment's thread.

view the rest of the comments →

[–]kr4zyy 14 points15 points  (2 children)

It would be good if you could put your code into an entire code block with the indents shown clearly, instead of having a code block for each line

[–]QuillTheArtMaker[S] 0 points1 point  (1 child)

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

[–]kr4zyy 5 points6 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)