Python Forum
Invalid syntax on IF function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Invalid syntax on IF function
#1
guessnumber=0

import random
Mystery = random.randint(0,9)

while guessnumber==int(input("Guess a number between 0-9: ")):
    if guessnumber > Mystery:
        print('The number you input is not the mystery number, try again.')
    guessnumber = int(input("Enter a guess: ")
if guessnumber == Mystery:
 print("you win!")
Error:
invalid syntax
This is what I did, but the error that i'm REALLY struggling with is that it always says invalid syntax in the end of the function IF which is obviously the colon, I need help with this.
Reply
#2
You miss a bracket in prev. line.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
(Jan-07-2018, 02:44 AM)wavic Wrote: You miss a bracket in prev. line.
Thanks.
Just a silly mistake.
Reply
#4
Please, always post full Traceback in error tags, not just the last line.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  print(data) is suddenly invalid syntax db042190 6 1,120 Jun-14-2023, 02:55 PM
Last Post: deanhystad
  [Solved] unkown (to me) function def parm "name1:name2" syntax. MvGulik 5 987 Nov-11-2022, 11:21 AM
Last Post: MvGulik
  meaning of -> syntax in function definition DrakeSoft 5 1,878 Apr-09-2022, 07:45 AM
Last Post: DrakeSoft
  SyntaxError: invalid syntax ?? korenron 15 5,575 Jan-25-2022, 11:46 AM
Last Post: korenron
  Invalid syntax with an f-string Mark17 7 7,567 Jan-14-2022, 04:44 PM
Last Post: Mark17
  invalid syntax in my class CompleteNewb 2 1,844 Dec-13-2021, 09:39 AM
Last Post: Larz60+
Star I'm getting syntax error while using input function in def. yecktmpmbyrv 1 1,932 Oct-06-2021, 09:39 AM
Last Post: menator01
Exclamation Invalid syntax error(Predict Ethereum Price) lulu43366 2 3,093 Sep-24-2021, 01:24 PM
Last Post: lulu43366
  Tuple generator, and function/class syntax quazirfan 3 3,761 Aug-10-2021, 09:32 AM
Last Post: buran
  Unexplained Invalid syntax Error cybertooth 5 3,176 Aug-02-2021, 10:05 AM
Last Post: cybertooth

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020