"Ожидается отступ"
После двоеточия в строке я получаю "ожидаемый блок идентификаторов": def StartGame(username): он остаётся красным до конца строки, и, будучи новичком в программировании, я не уверен, что делаю неправильно. Спасибо заранее:)
def StartGame(username):
print("This game is all about Trading and Adventuring.")
time.sleep(0.51)
print("This is what is in your inventory: %s" % Inventory)
time.sleep(1)
print("As you go around, you will start to lose hunger. You will need to buy food along the way.")
time.sleep(1)
print("You have %s Health Points (HP)" % UserHunger)
TO.SetRandName()
1 ответ
Решение
Похоже, вы смешиваете табуляции и пробелы. Используйте 4 пробела для отступа:
def StartGame(username):
print("This game is all about Trading and Adventuring.")
time.sleep(0.51)
print("This is what is in your inventory: %s" % Inventory)
time.sleep(1)
print("As you go around, you will start to lose hunger. You will need to buy food along the way.")
time.sleep(1)
print("You have %s Health Points (HP)" % UserHunger)
TO.SetRandName()
Также см. Абзац отступа PEP-8.