Advertisement
cwchen

Generate variable programmically

Jan 19th, 2016
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.11 KB | None | 0 0
  1. _g = globals()
  2. for i in range(1, 4):
  3.     _g['ball' + '_' + str(i)] = i * i
  4.  
  5. print(ball_1)
  6. print(ball_2)
  7. print(ball_3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement