-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroomTypeMaker.py
52 lines (35 loc) · 1.04 KB
/
roomTypeMaker.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
#CreateRoomList
#using pickling to learn about the process and to create a list that can be easily
#read, since I can use dictionaries which make everything so much easier.
import pickle
def addRooms():
with open("roomList.p","wb") as roomList:
while True:
roomName = input("Enter the room name: ")
if roomName == 'done':
break
roomChance = input("Enter the % chance of occurence: ")
roomTypes[roomName]=roomChance
pickle.dump(roomTypes,roomList)
def delRoom():
with open("roomList.p","rb") as roomList:
roomName = input("Enter the room name to delete: ")
roomTypes = pickle.load(roomList)
del roomTypes[roomName]
with open("roomList.p","wb") as roomList:
pickle.dump(roomTypes,roomList)
def viewList():
with open("roomList.p","rb") as roomList:
roomTypes = pickle.load(roomList)
print (roomTypes)
roomTypes = {}
while True:
option = input("Add or view List: ")
if option == "add":
addRooms()
elif option == "view":
viewList()
elif option == "del":
delRoom()
else:
break