Ask coding questions

← Back to all posts
Bad indent?
NathanWeems (5)

I posted this repl question awhile back, and I tried what the replier suggested but it isn't working. I need help

Answered by InvisibleOne (2979) [earned 5 cycles]
View Answer
Comments
hotnewtop
InvisibleOne (2979)


You need to have the if statements indented to the same level as you input right there.

NathanWeems (5)

@InvisibleOne That's what I was looking to fix, thank you

OldWizard209 (1531)

You don't need to do:

while feeling_determined == True:

You can just do:

while feeling_determined :

This will do the same thing because feeling_determined evaluates to True anyways.....

Coder100 (18146)

your if statements must be in the while loop for them to run in the while loop which you appear to want, so like this:

from random import randint
print('Weems Quest')
print('v1.8')
print('2020')
print('Brought to you by Random Games Inc, Abilene DV.')
feeling_determined = True
dash = ('=========================================')
lines = ('-----------------------------------------')
while feeling_determined == True:
  print(lines)
  print('Basic creatures are weak to Fire')
  print('Shadow creatures are weak to Water')
  print('Speedy creatures are weak to Physical attacks')
  print('You have 30 HP')
  print('The Goblin has 10 HP')
  player_hp = 30
  curr_enemy = "whatever"
  enemy_hp = 10
  choice = input()
  if choice == "fireball":
    enemy_hp = enemy_hp - 3
  elif choice == "water blast":
    enemy_hp = enemy_hp - 2
  elif choice == "strike":
    enemy_hp = enemy_hp - 1
  else:
    print("invalid input")
    feeling_determined = False
    #ok
VulcanWM (2766)

Can you send a screenshot of the error?