So basically I can't seem to get global variables in functions I import from a different file.
Also are the only scopes in python classes and functions?
Or is there a way to set your own scopes.
Like in C++ you can put {} brackets anywhere you like.
User Profile
Collapse
-
Global Variables Over Multiple Source Files
-
Pygame TypeError: python.surface object unsubscriptable
I am trying to run some pygame code and get this error:
Pygame TypeError: python.surface object unsubscriptable
Here is the code:
Code:ball1 = [ 100 ,50 , 1, 0] def ball (x,y,movex,movey): if x < 0 : x * -1 if x > 580: x= x* -1 if y < 0: y = y* -1 if y > 260: y = y*-1 x+= movex
-
That works great!!
The error:
'TypeError: 'NoneType' object is not subscriptable' /iterable
Was because I used 'return pieces' instead of 'return (pieces)'
-Thanks
mahem1 -
Python 'NoneType' Error
I want to print out list pieces without any zeros to make it more readable.
Part of this code is in a while loop.
Code:import copy pieces = [ [1,2,3,4,5,6] , [0,0,0,0,0,0], [0,0,0,0,0,0] ] def formatt (formatt) : while 0 in formatt[1] : formatt[1].remove(0) while 0 in formatt[2] : formatt[2].remove(0) while 0 in formatt[0] :
No activity results to display
Show More
Leave a comment: