Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
TSM_RX7

I keep getting syntax error's Python 3.7

Recommended Posts

Posted · Original PosterOP

I keep getting syntax error's Python 3.7 different errors every time  I am trying to make a guessing game for my coursework and it doesn't want to go ahead it keeps messing up every time can someone help  me, please ASAP

Here is the link to my Screenshot of what error have currently

https://gyazo.com/0186441188e06723da152da0b684cbba

This is my code currently

import random

def numberGuess():
  print("I'm thinking of a number between 1 and 10")
  randNum = random.randrange(1,11) # this line generates a random number
  while guess != randNum:
    guess = int(input("Try to guess the number:")) # ask user for a number
    if (guess == randNum):
      print ("You got it!")
      
    if (guess > randNum):
      print "Wrong! (You guessed too high)
    if (guess < randNum):
      print "Wrong! You guessed too low"

numberGuess()

 


 

CPU Intel i7 6800K  Unlocked CPU/Processor

Motherboard ASUS ROG STRIX Intel X99 RGB LED GAMING ATX Motherboard

RAM Corsair 32GB Vengeance LPX DDR4 2133MHz RAM/Memory Kit 2x 16GB 2x

GPU ASUS NVIDIA GeForce GTX 1060 DUAL O.C. 6GB - Graphics Card

Case Corsair Carbide SPEC-ALPHA Black/Red Gaming Case with Window

Storage 250GB Samsung 960 EVO M.2 NVME SSD

PSU Corsair RMi Series 850W Fully Modular Power Supply

Display(s) AOC E2460SH 24" LED Full HD 1ms Gaming Monitor

Cooling Pure Rock Slim Compact Intel/AMD CPU Air Cooler

Keyboard Corsair K70 Rapidfire Cherry Red Mechanical Backlit Gaming Keyboard

Mouse Corsair Vengeance M65 Performance FPS  Laser Gaming Mouse - Black

Sound Onboard High Definition Audio

Operating System Windows 10 Home 64Bit English OS DVD

Link to post
Share on other sites

You are missing a single double-quotes after the "Wrong! (You guessed too high) line.

 

In Python 3 it is the norm to use print using curved braces, as in the first time you did it. I have posted the correct version below.

 

import random

def numberGuess():
  print("I'm thinking of a number between 1 and 10")
  randNum = random.randrange(1,11) # this line generates a random number
  while guess != randNum:
    guess = int(input("Try to guess the number:")) # ask user for a number
    if guess == randNum:
      print("You got it!")
      
    if guess > randNum:
      print("Wrong! (You guessed too high)")
    if guess < randNum:
      print("Wrong! You guessed too low")

numberGuess()

 

Link to post
Share on other sites
Posted · Original PosterOP
12 minutes ago, CyberneticTitan said:

You are missing a single double-quotes after the "Wrong! (You guessed too high) line.

 

In Python 3 it is the norm to use print using curved braces, as in the first time you did it. I have posted the correct version below.

 


import random

def numberGuess():
  print("I'm thinking of a number between 1 and 10")
  randNum = random.randrange(1,11) # this line generates a random number
  while guess != randNum:
    guess = int(input("Try to guess the number:")) # ask user for a number
    if guess == randNum:
      print("You got it!")
      
    if guess > randNum:
      print("Wrong! (You guessed too high)")
    if guess < randNum:
      print("Wrong! You guessed too low")

numberGuess()

 

What about this issue https://gyazo.com/2751c74db5b079c5c5e7adaf2a7d408d


 

CPU Intel i7 6800K  Unlocked CPU/Processor

Motherboard ASUS ROG STRIX Intel X99 RGB LED GAMING ATX Motherboard

RAM Corsair 32GB Vengeance LPX DDR4 2133MHz RAM/Memory Kit 2x 16GB 2x

GPU ASUS NVIDIA GeForce GTX 1060 DUAL O.C. 6GB - Graphics Card

Case Corsair Carbide SPEC-ALPHA Black/Red Gaming Case with Window

Storage 250GB Samsung 960 EVO M.2 NVME SSD

PSU Corsair RMi Series 850W Fully Modular Power Supply

Display(s) AOC E2460SH 24" LED Full HD 1ms Gaming Monitor

Cooling Pure Rock Slim Compact Intel/AMD CPU Air Cooler

Keyboard Corsair K70 Rapidfire Cherry Red Mechanical Backlit Gaming Keyboard

Mouse Corsair Vengeance M65 Performance FPS  Laser Gaming Mouse - Black

Sound Onboard High Definition Audio

Operating System Windows 10 Home 64Bit English OS DVD

Link to post
Share on other sites
Posted · Original PosterOP
1 minute ago, CyberneticTitan said:

What do you think it means?

 

How would you debug this?

idk i am quite busy but i will try and debug it 


 

CPU Intel i7 6800K  Unlocked CPU/Processor

Motherboard ASUS ROG STRIX Intel X99 RGB LED GAMING ATX Motherboard

RAM Corsair 32GB Vengeance LPX DDR4 2133MHz RAM/Memory Kit 2x 16GB 2x

GPU ASUS NVIDIA GeForce GTX 1060 DUAL O.C. 6GB - Graphics Card

Case Corsair Carbide SPEC-ALPHA Black/Red Gaming Case with Window

Storage 250GB Samsung 960 EVO M.2 NVME SSD

PSU Corsair RMi Series 850W Fully Modular Power Supply

Display(s) AOC E2460SH 24" LED Full HD 1ms Gaming Monitor

Cooling Pure Rock Slim Compact Intel/AMD CPU Air Cooler

Keyboard Corsair K70 Rapidfire Cherry Red Mechanical Backlit Gaming Keyboard

Mouse Corsair Vengeance M65 Performance FPS  Laser Gaming Mouse - Black

Sound Onboard High Definition Audio

Operating System Windows 10 Home 64Bit English OS DVD

Link to post
Share on other sites
2 hours ago, CyberneticTitan said:

What do you think it means?

you are using 'guess' before it's actually set to anything.


Gaming build:

CPU: i7-7700k (5.0ghz, 1.312v)

GPU(s): Asus Strix 1080ti OC (~2063mhz)

Memory: 32GB (4x8) DDR4 G.Skill TridentZ RGB 3000mhz

Motherboard: Asus Prime z270-AR

PSU: Seasonic Prime Titanium 850W

Cooler: Custom water loop (420mm rad + 360mm rad)

Case: Be quiet! Dark base pro 900 (silver)
Primary storage: Samsung 960 evo m.2 SSD (500gb)

Secondary storage: Samsung 850 evo SSD (250gb)

 

Server build:

OS: Ubuntu server 16.04 LTS (though will probably upgrade to 17.04 for better ryzen support)

CPU: Ryzen R7 1700x

Memory: Ballistix Sport LT 16GB

Motherboard: Asrock B350 m4 pro

PSU: Corsair CX550M

Cooler: Cooler master hyper 212 evo

Storage: 2TB WD Red x1, 128gb OCZ SSD for OS

Case: HAF 932 adv

 

Link to post
Share on other sites

You have to create the variable guess before you start your loop, because your while loop uses the variable "guess"


#MakeBombs #Killedmywife

 

My Rig: i5 4670k @ 4.0GHZ - GIGABYTE GTX 1070 ti Windforce - Mixed 16GB Kit - Gigabyte Z87X-D3H - OCZ 850W 80+ Gold - NZXT H440 - Corsair H55 - 3x 1TB Seagate Barracuda and ADATA Marvel 256GB SSD

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×