Four letter phat


#1

Hi, need a little help please, not sure if I am making this harder than is necessary but, I have a raspberry pi with a four letter phat on, I am running a countdown timer, and I want to allow the user to “disarm” the counter if they entered the code word, but this is the bit I am struggling with ie where to put it and how to stop the rest of the program. initially I am wanting to run this for a cubs activity tomorrow evening however I was thinking this would be a lovely piece of code for an escape the room type of exercise. thanks

import time
import fourletterphat

minutes = 00
seconds = 10
disarm = 0

while disarm != "be prepared":
print ("armed")
# Calculate how long we need to count down for in seconds
start_time = time.time()
end_time = start_time + (minutes * 60) + seconds
run_time = end_time - start_time
curr_time = start_time

while curr_time < end_time:
curr_time = time.time()
remaining = end_time - curr_time
hundredths = int(remaining * 100)

# If greater than 59 seconds are left, display minutes + seconds
if int(remaining) > 59:
curr_minutes = int(remaining / 60.0)
curr_seconds = int(remaining % 60)
padded_str = str("{0:02d}".format(curr_minutes)) + str("{0:02d}".format(curr_seconds))

# Otherwise display seconds + hundreths of a second
else:
curr_seconds = int(remaining)
curr_hundredths = int(remaining * 100 % 100)
padded_str = str("{0:02d}".format(curr_seconds)) + str("{0:02d}".format(curr_hundredths))

fourletterphat.clear()
fourletterphat.print_str(padded_str)
fourletterphat.set_decimal(1, 1)
fourletterphat.show()

# Explosion display 
fourletterphat.clear()
fourletterphat.print_str("BOOM")
fourletterphat.show()
time.sleep(1 / 16.0)

#2

I think somewhere along the way the indentation has been lost from your code- could you re-paste it? My brain will melt-down trying to understand it :D