Forumite Members › General Topics › Tech › Makers & Builders › Programming/Code tips › Invalid syntax
- This topic has 4 replies, 3 voices, and was last updated 9 years ago by
Robin Long.
-
AuthorPosts
-
March 8, 2017 at 10:58 am #4938
My youngest and I have been starting to learn python with a view to buying a Raspberry Pi and doing some projects together. To help us, I brought Python Basics Level 1 by Chris Roffey.
There is an 8 Ball Programme within the book which won’t run stating there is an Invalid Syntax,
The syntax is happening at the ‘elif’ function:
if choice ==1:
answer =ans1
elif choice == 2:
answer =ans2despite re-entering the code it just throws back the same error if anyone can see something glaringly wrong, could you help a frustrated father out?
Cheers Knight,
RIP Spike09 Your Missed
If I'm not here, I'm there.Finally joined Twitter! longr79
March 8, 2017 at 11:04 am #4940my bad just discovered a missing/dodgey indent which appeared to be throwing the whole thing off
Cheers Knight,
RIP Spike09 Your Missed
If I'm not here, I'm there.Finally joined Twitter! longr79
March 8, 2017 at 12:46 pm #4941You found the one aspect of Python I HATE, it makes debugging a factor of 10 more difficult than using curly brackets or begin/end pairs.
If you are going to dabble on the hardware side there are two different and incompatible supporting libraries:
gpiozero with its documentation here.
and
RPi.GPIO with its docs here.
there are pros and cons to both packages, but gpiozero may be more user friendly.
No doubt you have already located the generic Python resources here.
and the Raspberry Pi MagPi resources.
March 11, 2017 at 11:34 am #5067If you haven’t found it, Geany (which is a development package) really helps with syntax problems, as well as navigating through larger projects, and is 100% free.
Disclaimer: I only use Linux, dunno if it’s available on other platforms.
Arch Linux, on a Ryzen 7 1800X, 32 GB, 5 (yes -5) HDs inc 5 SSDs, 4 RPi 3Bs + 1 RPi 4B - one as an NFS server with two more drives, PiHole (shut yours), Plex server, cloud server, and other random Pi stuff. Nice CoolerMaster case, 2 x NV GTX 1070 8GB, and a whopping 32" AOC 1440P monitor.
March 12, 2017 at 11:09 pm #5110Thanks @D-Dan I will look into it
Cheers Knight,
RIP Spike09 Your Missed
If I'm not here, I'm there.Finally joined Twitter! longr79
-
AuthorPosts
- You must be logged in to reply to this topic.
