+ 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
3 Réponses
+ 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
0
is there a lessoon that will talk about tabs?
15th Dec 2024, 7:31 PM
print ("python")
print ("python") - avatar