Sunday, December 1, 2024

LITTLE THINGS ABOUT PYTHON language

WE CAN CALL IT SHORT NOTES OF PYTHON CODE 

In Python language when we start to learn the python language. We face too much problems like, why range function does not print the last number , why 'break' create error when we use it only if else statements. So that kind of thing when we know. then we won't do it. we will look smart to other coders 

BREAKS
Break only exits the innermost loop in a nested loop. you can't use break to exit an if statement unless the if statement is inside of a loop 

LEN FUNCTION (LENGTH)
The Len() function used to determine the number of element in a sequence (like a string , list or tuple ), Let give you an example supposed that value = (23123) so this is a integer , not a sequence, Integer do not have a concept of "length" python raises a Type Error. 

SORT()

If you have a mutable list of elements that you want to arrange in ascending or descending order.
it doesn't work on data type like tuples or strings directly.
it doesn't work on dictionaries , set, or any object that isn't a list.

END=""
Formatting test on the same line.
creating custom output separators. space and dashes


  • If you know about more short things, you can mail me gyanendra2349128@gmail.com

No comments:

Post a Comment