Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 27193  / 2 Years ago, thu, january 6, 2022, 3:50:42

I started to learn python , but when I try to make an function I get this error



IndentationError: expected an indented block



I use the terminal and write python then start to write the function like that



>>> def mul (x,y) :
... ans=0
File "<stdin>", line 2
ans=0
^
IndentationError: expected an indented block


so what is the wrong thing i'm doing


More From » 14.04

 Answers
0

Python uses indentation to determine the grouping of statements. You can use one or more spaces or one or more tab, just that within the same statement always use one or the other. Is recommended to use spaces instead of tabs, but is not required. Read here



Try:



>>> def mul (x,y) :
... ans = 0
... print ans


with 2 before ans=0.



Read here for complete documentatio of python.


[#25118] Friday, January 7, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nalystcul

Total Points: 390
Total Questions: 106
Total Answers: 115

Location: Tokelau
Member since Sun, May 7, 2023
1 Year ago
;