Python if continue in the door

Asked 1 weeks ago, Updated 1 weeks ago, 7 views

//import random

print ("Name Generation")

Main character = input()
print "The name of the main character"
      f"{Heroine}")

while 1:
    power = random.randrange(3, 9)
    health = random.randrange(5, 9)
    mana = random.randrange(1, 5)
    luck = random.randrange(0, 3)

print(f"power = {power}, health = {health}, mana = {mana}, luck = {luck}")
print("Restat? Y/N")
A = input()
if A == "Y":

    print("GAME START")
if A == "N":
    print("OK GOD BLESS YOU")

    B = input()
if B == "Y":<<<
    continue

elif B == "N":
    print("Setting Complete")
    print(f"""
 [Status]
 Name = {Heroine}
 occupation = adventurer
 Physical strength = {health}
 Combat power = {power}
 Luck = {lucky}
 Mana = {mana}"")

<<< There was a continuation not professionally in loop error in the marked place, so I searched it It's called an indentation error, so even though I unified it with a tab and unified it with a space bar, the error keeps popping up

python continue

2022-09-19 23:22

1 Answers

If you have to operate from the print under the while statement to the while statement, you can indent it.

import random

print ("Name Generation")

Main character = input()
print "The name of the main character"
      f"{Heroine}")

while 1:
    power = random.randrange(3, 9)
    health = random.randrange(5, 9)
    mana = random.randrange(1, 5)
    luck = random.randrange(0, 3)

    print(f"power = {power}, health = {health}, mana = {mana}, luck = {luck}")
    print("Restat? Y/N")

    A = input()
    if A == "Y":
        print("GAME START")

    if A == "N":
        print("OK GOD BLESS YOU")

    B = input()
    if B == "Y":
        continue

    elif B == "N":
        print("Setting Complete")
        print(f"""
 [Status]
 Name = {Heroine}
 occupation = adventurer
 Physical strength = {health}
 Combat power = {power}
 Luck = {lucky}
 Mana = {mana}"")


2022-09-19 23:22

If you have any answers or tips


© 2022 pinfo. All rights reserved.