forked from johnrobertvincent/python
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitch.py
More file actions
Latest commit
32 lines (22 loc) · 741 Bytes
/
Copy pathswitch.py
File metadata and controls
32 lines (22 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#light switch on/off
defswitch():
globalcurrent
original=raw_input("Switch On/Off:").lower()
iforiginal=="on":
ifcurrent==original:
print("The light is already on. Try again!")
else:
print("The light is now on.")
current=original
eliforiginal=="off":
ifcurrent==original:
print("The light is already off. Try again!")
else:
print("The light is now off.")
current=original
else:
print("What you entered is not a correct option. Try again!")
#Loop Program with the current state of the switch set to off
current="off"
whileTrue:
switch()