Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def menu():
- while True:
- print('Please choose one of the following options: ')
- print('1. Read a file numbers')
- print('2. Sort the numbers from file')
- print('3. Quit the program\n')
- command = int(input("Enter a command: "))
- if command == 1:
- print("Reading the file numbers.txt")
- valid = False
- try:
- f = open('numbers', 'r')
- valid = True
- except IOError:
- print("That file does not exist!")
- if valid:
- numbers(f)
- f.close()
- elif command== 2:
- heap_sort(heap[1:])
- elif command == 3:
- print('Program is now terminating')
- break
- else:
- print("Invalid input number.\n")
- def numbers(nums):
- test=[]
- for _ in nums:
- test += _.split()
- for i in test:
- heap_insert(heap,int(i))
- print("All numbers have been inserted")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement