Skip to content

Commit c7fd827

Browse files
committed
Display rooms in status using f-strings
1 parent c008065 commit c7fd827

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Zombie-House/main.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#!/bin/python3
22

3-
# Remix from original project published by Raspberry Pi Foundation
4-
# https://projects.raspberrypi.org/en/projects/rpg
3+
'''
4+
Remix from original project published by Raspberry Pi Foundation
5+
https://projects.raspberrypi.org/en/projects/rpg
6+
Integrated code from https://github.com/xAptive
7+
Converted code to use f-strings (available in Python 3.6 and newer)
8+
'''
59

610
# NOTE: This code is in the 'working' branch
711

@@ -27,16 +31,19 @@ def showInstructions():
2731
def showStatus():
2832
# print the player's current status
2933
print('---------------------------')
30-
print('You are in the ' + currentRoom)
34+
print(f"You are in the {currentRoom}")
3135
# print the current inventory
32-
print('Inventory : ' + str(inventory))
36+
print(f"Inventory : {str(inventory)}")
37+
# print the available directions
38+
for direction in rooms[currentRoom]['directions']:
39+
print(f"The {rooms[currentRoom]['directions'][direction]} is {direction}")
3340
# print an item, monster or poison if there is one
3441
if "item" in rooms[currentRoom]:
35-
print('You see a ' + rooms[currentRoom]['item'])
42+
print(f"You see a {rooms[currentRoom]['item']}")
3643
if "monster" in rooms[currentRoom]:
37-
print('There is a ' + rooms[currentRoom]['monster'] + ' in the room!')
44+
print(f"There is a {rooms[currentRoom]['monster']} in the room!")
3845
if "poison" in rooms[currentRoom]:
39-
print('There is some ' + rooms[currentRoom]['poison'] + ' in the room!')
46+
print(f"There is some {rooms[currentRoom]['poison']} in the room!")
4047
print("---------------------------")
4148

4249
# An inventory, which is initially empty

0 commit comments

Comments
 (0)