Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 syntax error in an if statement at the else ?
Hi, I'm totally a nob to programming and just started with Python, so please forgive me if I'm not yet too familiar with the terms.

I'm trying to define a way which a code can be reuse to allow user to change the color of the turtle object. However, I keep getting error when I run it in the shell.

The error that I get in shell is saying error in line "else pc == "red": saying it is invalid syntax, the line that I ran is square("red").

I appreciate any help anyone can point out.

import turtle
pointer = turtle.Turtle()
increase = input("Enter amount to expand image.")
increase = int(increase)
side = input("How many pixels for each side?")
side = int(side)

def square(pc):
    if pc == "white":
    elif pc == "black":
    else pc == "red":
    for box in range(4):
else shouldn't have a condition its just
Thanks, Yoriz that's exactly what it was.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Syntax Error: Invalid Syntax in a while loop sydney 1 164 Oct-19-2019, 01:40 AM
Last Post: jefsummers
  Syntax error for code that seems correct mcnhscc39 4 665 Nov-15-2018, 08:40 PM
Last Post: j.crater
  Syntax Error bonnerj 1 851 Feb-07-2018, 12:41 PM
Last Post: metulburr
  invalid syntax error penlemon 4 1,074 Jan-27-2018, 02:46 PM
Last Post: sparkz_alot
  Reaction tester syntax error Oli 1 881 Oct-11-2017, 07:26 PM
Last Post: ichabod801
  Syntax error in def Beatenberg 8 2,253 Oct-09-2017, 01:41 PM
Last Post: ichabod801
  Can't figure out syntax error pythonnewb 3 1,590 Jul-16-2017, 12:03 AM
Last Post: pythonnewb
  Syntax Error bsullivan1983 9 3,273 Jun-06-2017, 05:52 PM
Last Post: nilamo
  syntax error, and call functions. Ayiden 3 1,579 Mar-23-2017, 03:32 PM
Last Post: sparkz_alot

Forum Jump:

Users browsing this thread: 1 Guest(s)