-
Notifications
You must be signed in to change notification settings - Fork 1
/
linear_hashtable_functions_input.py
55 lines (33 loc) · 1.55 KB
/
linear_hashtable_functions_input.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
from linear_hashtable_functions import *
def inputNumber():
phone_number = input("Please Enter a Pakistani 11 digits Phone Number: \n >>>> ")
if phone_number.isalpha() or " " in phone_number or "." in phone_number or len(phone_number) != 11 or not phone_number.isdigit() or phone_number[0] != "0":
print("Please enter a valid 11 digits Pakistani Phone Number e.g 03181236267")
print("Try Again! \n")
return inputNumber()
return phone_number
def inputLinearOptions():
print("1) Search")
print("2) Insert")
print("3) Delete\n")
print("========= Select an Option to continue =========\n")
option_number = input(">>>> ")
if option_number.isalpha() or " " in option_number or "." in option_number or len(option_number) != 1 or not option_number.isdigit() or (option_number != "1" and option_number != "2" and option_number != "3"):
print("Please enter a valid number (1 or 2 or 3)!")
print("Try Again! \n")
return inputLinearOptions()
return int(option_number)
def showOptions(linear_hashtable):
print("\n============ Open Addressing (Linear Probing) ============\n")
user_option = inputLinearOptions()
if user_option == 1:
hashSearch(linear_hashtable)
if user_option == 2:
hashInsert(linear_hashtable)
if user_option == 3:
hashDelete(linear_hashtable)
while True:
break_input= input("Please Press ENTER to return back to main menu!")
if break_input == "":
break
showOptions(linear_hashtable)