텍스트 기반 던전 게임을 만들려고합니다. 그냥 재미와 연습을 위해 파이썬에 문제가있어 if 블록을 따르지 않는다. 기이 한 일은 처음 입력했을 때 작동한다는 것입니다.하지만 나중에는 그렇지 않습니다. 그것은 모든 조건이 사실 인 것처럼 다루고 있습니다.if 문장을 따르지 않는 파이썬
choosing_race = True
while choosing_race == True:
print("options: Human, Elf, Dwarf")
p['race'] = input("Choose Race: ",)
print(p['race'], choosing_race)
if p['race'] == "Elf" or "elf":
print()
print("Elves are nimble, both in body and mind, but their form is frail. They gain Bonuses to Intelligence and Dexterity and a Penalty to Constitution")
print()
confirm_race = input("Are you an Elf? ",)
if confirm_race == "yes" or "Yes":
p['int_mod_r'] = 2
p['dex_mod_r'] = 2
p['con_mod_r'] = -2
choosing_race = False
elif confirm_race == "no" or "No":
print()
print("ok, select a different race")
else:
print()
print("Could not confirm, try again")
P 개의 [레이스] 입력 잘 보여 주지만 I 아무것도 (예 오리)를 입력하고 난 ELF를 입력 한 경우로서이 작용한다. confirm_race에 요청하면 항상 예를 반환합니다. 나는 거기에 오타를 넣었 음에 틀림 없다고 생각하지만 그것을 발견 할 수 없다. 나는 내 들여 쓰기를 다시했지만 여전히 운이 없다. 나는 기능으로 구조 조정하려고 노력할 것이고 어쩌면 도움이 될 것입니다. 그 동안 내가 무엇이 잘못되었는지 알고 싶기 때문에 장래에 막을 수 있습니다. 감사. 당신은이 경우
if p['race'] == "Elf" or "elf":
같은 라인에서 기대하는 행동을 못하고있다
:'is_a_valid_choice = [ 'human', 'elf', 'dwarf']에서 lower() [ – Alexander