-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelevator.py
More file actions
33 lines (27 loc) · 859 Bytes
/
Copy pathelevator.py
File metadata and controls
33 lines (27 loc) · 859 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
33
electricity = True
current = 0
ground_floor = 0
top_floor = 5
def up(present, dest):
while present < dest:
print("going up")
present += 1
return present
def down(present, dest):
while present > dest:
print("going down")
present -= 1
return present
while electricity:
destination = int(input("enter the destination floor"))
if ground_floor <= destination <= top_floor:
if destination < current:
current = down(current, destination)
print("Elevator @ floor {}".format(current))
if destination > current:
current = up(current, destination)
print("Elevator @ floor {}".format(current))
else:
print("You're in this floor ->{}".format(destination))
else:
print("There are only {} floors".format(top_floor))