-1
I have a Dungeon code, in which the user can choose path 1 or path 2, each path leads to a room. In case he reaches room 8 I need a value between 1 and 5 to be drawn and return the respective room to this value. (I cannot use more than one if, Elif or Else within my loop)
from random import randrange
import os
os.system('CLS')
tentativas = 1
sala = 1
while tentativas <= 7 and sala <= 7 and sala:
print("Você está na sala: {}\nEscolha seu caminho".format(sala))
print("[1] - Caminho Vermelho\n[2] - Caminho Preto")
escolha = int(input())
if escolha == 1:
sala += 1
elif escolha == 2:
sala += 2
else:
("Não existe esse caminho!")
os.system('CLS')
tentativas += 1
if tentativas >= 7:
print("Você gastou todos seus recursos, não há mais saidas, você e seus companheiros morreram")
elif sala == 9:
print("Você está na sala: {}\nVocê venceu!!".format(sala))
elif sala == 8:
sala = input(randrange(1, 5))
I would like a solution where when generating the randrange my code returned inside the loop.
can you fix the code? you have separated into several blocks and have missing indentation

coloque tudo assim

– Tiago Dinis
Could format the code for a better view?
– Danizavtz
In your first while failed to inform the expression for variable room.
– Pablo Leonardo