Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #4938
    Robin LongRobin Long
    Participant
      @knightmare007
      Forumite Points: 12

      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 =ans2

      despite 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

      #4940
      Robin LongRobin Long
      Participant
        @knightmare007
        Forumite Points: 12

        my 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

        #4941
        Ed PEd P
        Participant
          @edps
          Forumite Points: 39

          You 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.

           

           

           

          #5067
          D-DanD-Dan
          Participant
            @d-dan
            Forumite Points: 6

            If 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.

            #5110
            Robin LongRobin Long
            Participant
              @knightmare007
              Forumite Points: 12

              Thanks @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

            Viewing 5 posts - 1 through 5 (of 5 total)
            • You must be logged in to reply to this topic.