repl.it
@MerlinKnight/

queues question 1

Python

No description

fork
loading
Files
  • main.py
main.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
def menu(array,array_l,array_b,array_f):
  choice = int(input("Enter question number: "))
  if choice == 1:
    full(array,array_l,array_b,array_f)
  if choice == 2:
    new(array,array_l,array_b,array_f)

def full(array,array_l,array_b,array_f):
  arrayl = len(array)
  if arrayl == array_l:
    print("Array is full")
  else:
    print("Array is not full")
  menu(array,array_l,array_b,array_f)
  
def new(array,array_l,array_b,array_f):
  arrayl = len(array)
  if arrayl == array_l:
    print("Array is full")
  else:
    newi = str(input("Input new item: "))
    array.append(newi)
    print(array)
    arrayl = len(array)
    array_b = arrayl - 1
    print("The back pointer is now at",array_b)
  if arrayl == 1:
    array_f = array_b
    print("The front pointer is now at",array_f)
  menu(array,array_l,array_b,array_f)

array_f = 0
array_l = 8
array_b = 3
array = ["cat","dog","fish","mouse"] 
menu(array,array_l,array_b,array_f)
Fetching token
?