When I run this python script led.py
it works.
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(24,GPIO.OUT)
print("LED on")
GPIO.output(24,GPIO.HIGH)
time.sleep(1)
print("LED off")
GPIO.output(24,GPIO.LOW)
but if I open python3 shell and paste the above code
script# python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO as GPIO
>>> import time
>>> GPIO.setmode(GPIO.BCM)
>>> GPIO.setwarnings(False)
>>> GPIO.setup(24,GPIO.OUT)
>>> print("LED on")
LED on
then it does not work. what is happening here