+ 1
What is wrong with my code?
I was trying to make a console game in python, but i am getting an error of which i do not know how to solve. The block of code is the following: class player: def __init__(self): if difficulty == 'easy': #code elif difficulty == 'normal': #code And this is the error that I am getting: File : "..\Playground\", line 12 elif difficulty == 'normal': ^ IndentationError: Expected an intented block Could anyone explain what i am doing wrong?
3 Respuestas
+ 12
Try this:
class player:
def __init__(self):
if difficulty == 'easy':
print ('easy')
elif difficulty == 'normal':
print ('normal')
+ 11
Glad I could help 😀
+ 1
@Micheal Foster Thanks! It is working now. The code must have been thinking that elif was a part of the if statement.