Our snake game only has one vital piece missing: food. Up until this point, there has been no randomness. Now that changes, so start by adding import random at the top of the file. Now, just above the while loop, we need to create a function that will set a new, random food location. We'll introduce a new food_pos (global) variable, and set it to a new Vector2 object we create with random x and y : def place_food (): global food_pos food_pos = pygame . Vector2 ( random . randrange ( W ), random . randrange ( H ) ) Enter fullscreen mode Exit fullscreen mode The variable has to be declared global inside the function, or else Python would create a local variable that exists only inside the function, and then disappears. By using the global keyword, we let the function know to create or update the variable in the global namespace. This is a good start, but it's not quite done. There is a chance that it will randomly choose a position that the snake occupies. That shouldn't be allowed.…