forked from mouredev/roadmap-retos-programacion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjuanchernandezdev.py
73 lines (53 loc) · 1.33 KB
/
juanchernandezdev.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
### Python Stracks And Queues ###
#! Stack
my_stack = []
print(my_stack)
my_stack.append(55)
my_stack.append(15)
my_stack.append(30)
my_stack.append(18)
print(my_stack)
my_stack.pop(-1)
print(my_stack)
#! Queue
my_queue = []
print(my_queue)
my_queue.append(120)
my_queue.append(15)
my_queue.append(88)
my_queue.append(4)
print(my_queue)
my_queue.pop(0)
print(my_queue)
#! Optional Challenge
my_stack = []
def navigation():
while True:
direction = input(f'Please enter an URL, "next", "before" to navigate or "exit" to stop the program: ').lower()
if direction == 'exit':
print('Exiting program')
break
elif direction == 'next':
pass
elif direction =='before':
my_stack.pop()
else:
my_stack.append(direction)
print(my_stack[len(my_stack) - 1])
navigation()
print_queue = []
def printer():
while True:
info = input(f'Please enter a document name, "print" to print a document, or "exit" to quit the program: ').lower()
if info == 'exit':
print('Exiting printer program.')
break
elif info == 'print':
if len(print_queue) > 0:
print(f'printing {print_queue.pop(0)}...')
else:
print('Print queue is empty')
else:
print_queue.append(info)
print(f'Documents in queue {print_queue}')
printer()