What does "'Float' object cannot be interpreted as an integer" mean and how can i help it - Python error
Question: I was trying to follow simple instructions on how to build a game in python
but for some reason it is not working and whenever i type this code in:

    
    
    import pygame
    from pygame.locals import *
    
    pygame.init()
    width, height = 640, 480
    screen=pygame.display.set_mode((width, height))
    
    keys = [False, False, False, False]
    playerpos=[100,100]
    
    
    player = pygame.image.load("resources/images/dude.png")
    grass = pygame.image.load("resources/images/grass.png")
    castle = pygame.image.load("resources/images/castle.png")
    
    while 1:
        screen.fill(0)
    #Its this bit 'for' instruction that comes up with the error 
        for x in range(width/grass.get_width()+1):
            for y in range(height/grass.get_height()+1):
    
                screen.blit(grass,(x*100,y*100))
        screen.blit(castle,(0,30))
        screen.blit(castle,(0,135))
        screen.blit(castle,(0,240))
        screen.blit(castle,(0,345))
        screen.blit(player,playerpos)
        pygame.display.flip()
        for event in pygame.event.get():
            if event.type==pygame.QUIT:
                pygame.quit()
                exit(0)
    

It says: File "/Pygame/game.py", line 18, in for x in
range(width/grass.get_width()+1) TypeError: 'float' object cannot be
interpreted as an integer

the website that i'm following is:
<https://www.raywenderlich.com/24252/beginning-game-programming-for-teens-
with-python>

If someone could tell me what I'm doing wrong it would be much appreciated, if
not just explaining what the error means might help. Thanks so much


Answer: This is happening because `width/grass.get_width()` returns a float rather
than an int. The tutorial you're using specifically says to use Python 2.7, so
you may run into other issues like this if you continue it with Python 3, but
to fix this specific issue you can replace `/` with `//` to use integer
division.

