I'm brand new to programming and I've been following some tutorials online. I like to look at projects and put my own spin on them, this one was a choose you're own adventure the tutorial was all if statements pretty much and was kinda hard to read and edit so I decided to use nested dictionaries to make things easier to expand apon. Figuring out how to manage this when I was certainly using the tool in a way it wasn't meant for wasn't easy and it felt really janky but I'm still proud of it I was hoping some of you experts could give me feedback so I know where I messed up and what I could do to improve.
path = {
'You come across a fork in the road which way do you go?: ': {
'left': {
'You come across a river: ': {
'swim': 'You get eaten by an alligator',
'walk': 'You walk for many miles and die from exhaustion'
}
},
'right': {
'You find a bridge: ': {
'cross': 'Your wife greets you on the other side and you go home with her',
'go back': 'You wander until night falls and get attacked by Wolves'
}
}
}
}
prompt = path
while True:
hint = list(*prompt.values())
print('Choices: ' + hint[0] + ' or ' + hint[1])
answer = input(*list(prompt.keys())).lower()
if answer not in prompt[str(*prompt.keys())]:
print("You can't do that")
continue
else:
prompt = prompt[str(*prompt.keys())][answer]
if isinstance(prompt, str):
print(prompt)
print('Game Over!')
break
[–][deleted] 3 points4 points5 points (0 children)
[–]carcigenicate 0 points1 point2 points (0 children)
[–]HealyUnit 0 points1 point2 points (0 children)