Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unexpected syntax error
#4
Just wondering, are there expected syntax errors?

Your indentation is all over the place. Fix that.

This is where I get a syntax error:
else retry == "n": # if no the loop is closed 
The reason is else can only be followed by :, not another condition. If you want another condition use elif as you did here:
elif score == 3 or score == 4:
From the Python documentation:

https://docs.python.org/3/reference/comp...-statement
8.1. The if statement
The if statement is used for conditional execution:

if_stmt ::=  "if" assignment_expression ":" suite
             ("elif" assignment_expression ":" suite)*
             ["else" ":" suite]
I hate to be a RTFM guy, but when you are learning a programming language it is a really good idea to read the manual. You don't have to read everything at once, but at least read it piecemeal. If you are having a problem at an "if ... else" go look at the documentation for if/else.

I also think it is a good idea to read the documentation in its entirety. Devote some of your "Python time" to reading a section from the language reference or reading about one of the standard libraries.
Reply


Messages In This Thread
Unexpected syntax error - by djwilson0495 - Aug-24-2020, 10:21 AM
RE: Unexpected syntax error - by ndc85430 - Aug-24-2020, 10:26 AM
RE: Unexpected syntax error - by djwilson0495 - Aug-24-2020, 11:47 AM
RE: Unexpected syntax error - by deanhystad - Aug-24-2020, 01:27 PM
RE: Unexpected syntax error - by djwilson0495 - Aug-24-2020, 02:48 PM
RE: Unexpected syntax error - by deanhystad - Aug-24-2020, 04:18 PM
RE: Unexpected syntax error - by djwilson0495 - Aug-25-2020, 10:42 AM
RE: Unexpected syntax error - by deanhystad - Aug-25-2020, 01:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question A unexpected indent error Zyh3rbr0 4 1,079 Dec-14-2024, 04:45 PM
Last Post: deanhystad
  POST Syntax error amplay 0 656 Aug-07-2024, 02:43 PM
Last Post: amplay
  is this really a syntax error? Skaperen 4 1,639 May-25-2024, 07:31 AM
Last Post: snippsat
  World Clock syntax error OscarBoots 1 1,124 May-03-2024, 05:20 AM
Last Post: snippsat
  Syntax error for "root = Tk()" dlwaddel 15 6,550 Jan-29-2024, 12:07 AM
Last Post: dlwaddel
Photo SYNTAX ERROR Yannko 3 1,331 Jan-19-2024, 01:20 PM
Last Post: rob101
  Syntax error while executing the Python code in Linux DivAsh 8 5,029 Jul-19-2023, 06:27 PM
Last Post: Lahearle
  Code is returning the incorrect values. syntax error 007sonic 6 3,030 Jun-19-2023, 03:35 AM
Last Post: 007sonic
  syntax error question - string mgallotti 5 2,676 Feb-03-2023, 05:10 PM
Last Post: mgallotti
  Syntax error? I don't see it KenHorse 4 2,778 Jan-15-2023, 07:49 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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