+ 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?

10th Apr 2017, 6:14 PM
kevin
kevin - avatar
3 ответов
+ 12
Try this: class player: def __init__(self): if difficulty == 'easy': print ('easy') elif difficulty == 'normal': print ('normal')
10th Apr 2017, 6:28 PM
Michael Foster
Michael Foster - avatar
+ 11
Glad I could help 😀
10th Apr 2017, 6:37 PM
Michael Foster
Michael Foster - avatar
+ 1
@Micheal Foster Thanks! It is working now. The code must have been thinking that elif was a part of the if statement.
10th Apr 2017, 6:35 PM
kevin
kevin - avatar