New course! Every coder should learn Generative AI!
Try a free lesson+ 4
with open('rr.txt', 'rt') as f:
for line in f:
if line.strip() == 'On':
print('on')
else:
print('off')
break
alternative to the third line:
if 'On' in line.strip():
(if there's more text in the first line than just 'On')