I'm an absolute beginner when it comes to python and raspberry pi, I'm trying to just print a button pressed log when I press the button, however, I keep getting many errors. and after hours of struggling, i'm at the last one which says and excuse me for such a noob question but it says invalid syntax. now have googled python syntax and according to me what I have atm is correct. could someone help me out and explain what is happening? Thanks
The error is :
File "test.py", line 1 syntax Error : invalid syntax
test.py
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
input_state = GPIO.input(18)
if input_state == False:
print('Button Pressed')
time.sleep(0.2)