If you're going to post python code you need to wrap it in [code][/code] tags. That retains the formatting.Code:
from gpiozero import MotionSensorimport randomimport ospir = MotionSensor(23) while True: pir.wait_for_motion() songs = [f for f in os.listdir("/home/jasonc/Music") if f.endswith(".mp3")] song = random.choice(songs) os.chdir("/home/jasonc/Music") os.system("vlc " + song)
It makes the difference between:
if code_tags = "used":
print ("Python code is formatted")
else:
print ("Python code is scrambled")
And:
Code:
if code_tags = "used": print ("Python code is formatted")else: print ("Python code is scrambled")
Statistics: Posted by DougieLawson — Sun Apr 28, 2024 10:01 am