+ 1

Im on the working with data lesson but when i look at other code, why do they have TABSwhyyyyyyyyyyyyy

It looks weird and makes it just look more complicated for no reason. If theres a reason of the tabs let me know because i did not learn it yet

15th Dec 2024, 4:53 AM
print ("python")
print ("python") - avatar
7 Answers
+ 1
When you get to if blocks and functions it will explain more
16th Dec 2024, 3:56 PM
Slick
Slick - avatar
+ 2
It all has to do with the scope of a line of code. Tabs (or indentations) make it so certain blocks of code are only accessable through specific actions or conditions. # example 1 # the if block: number = 7 if number > 5: print("number is greater than 5") elif number < 5: print("number is less than 5") * in this example tabs are used so certain code will be executed depending on the value of the variable called "number". # example 2 # defining a function: def afunc(): print("This is a function") *using a tab here will cause the indented code block to execute when the function name is called. without the tab, the print line would just be executed and the function would do nothing.
15th Dec 2024, 11:22 AM
Slick
Slick - avatar
+ 1
Heres a axaple. By the way i dont know what this is but its an axaple https://sololearn.com/compiler-playground/cLjH6Jv1VYoR/?ref=app
15th Dec 2024, 4:58 AM
print ("python")
print ("python") - avatar
+ 1
is there a lessoon that will talk about tabs?
15th Dec 2024, 7:31 PM
print ("python")
print ("python") - avatar
+ 1
thank you
17th Dec 2024, 5:51 AM
print ("python")
print ("python") - avatar
+ 1
no there isnt print ("JUMP_LINK__&&__python__&&__JUMP_LINK") indentation is neccesary and python is heavily indentation dependant, plus it dosent make it more complicated, it makes it much more readable. once one gets better at reading code then itll come in handy
19th Dec 2024, 5:14 PM
Johnny Robertson (Xmosity)
Johnny Robertson (Xmosity) - avatar
+ 1
Good news I now know why there are tabs in python and its all because of a book Look at this for what i mean by the book (the link is in the quesion) You may not understand the question but the book is there and feel free to answer the question https://sololearn.com/discuss/3312853/?ref=app
31st Dec 2024, 10:24 PM
print ("python")
print ("python") - avatar