user3282362
user3282362

Reputation: 1

Python Type Error

hey so i've been getting a type error that says "traceback (most recent call last): File "(stdin)", line 1 in, (module) TypeError: unsupported operand type(s) for -: 'str' and 'int'

The entire code is:

    # 1 - Import library
    ... import.pygame
    from pygame.locals import *
    # 2 - Initialize the game
    ... pygame.init() 
    (6, 0)
    "width", "height" - 640, 480

then the error message occurs after that please help me to fix it because i'm clueless.

Upvotes: 0

Views: 151

Answers (3)

Google User
Google User

Reputation: 1

Just Do this :

import pygame 

from pygame.locals import * 

pygame.init()

width , height = 640,480

Upvotes: 0

Hugh Bothwell
Hugh Bothwell

Reputation: 56624

The error is definitely due to "height" - 640 because you can't subtract an integer from a strong.

I would guess that the minus sign is a typo, and that the line should actually read

width, height = 640, 480   # VGA screen resolution

Upvotes: 0

GreatSUN
GreatSUN

Reputation: 50

Sorry, but I can not identify a working code and therefore analyze the error in total, so I am just referencing a tutorial example now.

In my opinion, you are not defining width and height as they should be defined (should be defined for/as resolution.

See a simple example here: http://jonasbsb.jo.funpic.de/hendrix/pygame-example.html

Hope this helps.

Upvotes: 1

Related Questions