title: I'm having trouble with a Python Snake game using curses
body: <p>Update:
  I have fixed some parts of my code and now the snake game starts up :)
  Its only when the snake eats the food that the score doesn't go up and the food does not appear in a random location</p>
  <p>The guide that I have been using: <a href="https://www.youtube.com/watch?v=M_npdRYD4K0" rel="nofollow noreferrer">https://www.youtube.com/watch?v=M_npdRYD4K0</a></p>
  <pre><code>snake = [(4, 12), (4, 11), (4, 10)]
  food = [10, 30]
  
  stdscr.addch(food[0], food[1], '%')
  
  # game code or game logic
  
  ESC = 27
  key = KEY_RIGHT
  
  score = 0
  
  while key != ESC:
      
      stdscr.addstr(0, 2, 'Score ' + str(score) + ' ') 
      stdscr.timeout(150 - (len(snake))//5 + len(snake)//10 % 120)    
      
      prevKey = key
      event = stdscr.getch()                                          
      key = event if event != -1 else prevKey
      
      if key not in [KEY_LEFT, KEY_DOWN, KEY_RIGHT, KEY_UP, ESC]:    
          key = prevKey
          
      y = snake[0][0]                                            
      x = snake[0][1]                                             
      
      if key == KEY_UP:
          y -= 1
      if key == KEY_LEFT:
          x -= 1
      if key == KEY_RIGHT:
          x += 1
      if key == KEY_DOWN:
          y += 1
          
      snake.insert(0, (y, x))
      
      # The snek will go through the boundaries, and out to the other side
      if y == 0: y = 18
      if y == 19: y = 1
      if x == 0: x = 58
      if x == 59: x = 1
      
      # if the snek hits itself it will break the program
      if snake[0] in snake[1:]:
          print(&quot;You hit yourself...&quot;)
          break
      
      if snake[0] == food:
  
          score += 1
          food = ()
          while food == ():
              food = (randint(1, 18), randint(1, 58))
              if food in snake:
                  food = ()
          stdscr.addch(food[0], food[1], '%')
      else:
          last = snake.pop()
          stdscr.addch(last[0], last[1], ' ')
      stdscr.addch(snake[0][0], snake[0][1], '*')
  
  curses.endwin()
  print(&quot;\nYour final score: %s&quot; % score)
  </code></pre>