+ 5

How to do a indentation in python?

26th Nov 2022, 8:12 PM
Iyed Mabrook
Iyed Mabrook - avatar
15 Answers
+ 7
if you wanna add an indentation to say a file or print it, just in your print statement put print(" "). Btw theres 4 spaces in there. If you just mean when your writing code then: on pc press tab (near top left of your keyboard) on mobile on sololearn press tab (top left of your keyboard) any other time where tab isn't available just hit space 4 times also \t
26th Nov 2022, 9:02 PM
TriFoxi
TriFoxi - avatar
+ 6
Yea, You can use 4 space or 2 space for tab to indentation in Python If (a>b): print (a) //4 space or 2 space Something like that...
26th Nov 2022, 8:24 PM
Sâñtôsh
Sâñtôsh - avatar
26th Nov 2022, 9:08 PM
TriFoxi
TriFoxi - avatar
+ 4
You can use space as your indentation by clicking the space bar four times
27th Nov 2022, 12:41 PM
Sokkai
Sokkai - avatar
+ 3
lol thx Sâñtôsh
26th Nov 2022, 9:05 PM
TriFoxi
TriFoxi - avatar
+ 2
Nice advice TriFoxi
26th Nov 2022, 9:03 PM
Sâñtôsh
Sâñtôsh - avatar
+ 2
Ur welcome TriFoxi Are you beginner ??
26th Nov 2022, 9:07 PM
Sâñtôsh
Sâñtôsh - avatar
+ 1
Indentation works in some expressions such as conditional expression. Indentation refers to the spaces at a beginning of a code line. I would like to mention one example of conditional expression where indentation is used:- If (5>2) : print("five is greater than two. ")
27th Nov 2022, 11:17 AM
Anonymous
Anonymous - avatar
+ 1
Soo you have to chose wich form of indentation you use if you use 4 spaces than you have to use the 4 spaces in your whole code if you mixed it with tabs than you get an error. Maybe you align all the code to the left side and indent it again and dont forget use 4 Spaces OR tab NOT both That should fix your error
27th Nov 2022, 3:38 PM
S3R43o3
S3R43o3 - avatar
+ 1
Indentation is very important in python and use of indentation in python is given below:- if 5>3: print("Five is greater than three. ")
28th Nov 2022, 6:55 AM
Anonymous
Anonymous - avatar
+ 1
S3R43o3 Each block must have the same indentation, but different blocks in your code can have different levels of indentation.
28th Nov 2022, 3:21 PM
Steve
Steve - avatar
+ 1
Anonymous ofc on block 4 spaces or 1 tab … if you need more cause if statements or so on you have to do 8 spaces or 2 tabs and so on …
28th Nov 2022, 7:02 PM
S3R43o3
S3R43o3 - avatar