environment windows7 (I want a Mac Book Pro 16inch) Visual Studio Code chrome python ver3.8.3
This article is written for beginners in programming and Python.
What is the len function? The characters may be difficult to see on a PC. l L, e E, n N de len. This function tells you the length of the string and the number of elements written in the argument (hikisu).
I'm wondering "what is that?", But it's a function that I sometimes see when writing various code. Maybe programming needs the length of this string and the number of elements. So how do you write it? Python #function 2 for super beginners of Python As mentioned in the len function A built-in function that does not return a return location. The writing method is very simple.
len.py
len('String')
is.
For example
len.py
print(len('Michael Jackson'))
#15
print(len('Good morning World'))
#10
In this way, the length (number) of the character string is output.
Next is the number of elements. Lists and dictionaries output like this.
len.py
print(len(["Billie Eilish", "Beyoncé", "John Legend"]))
#3
print(len({"Ariana Grande": 1993, "LionelRichie": 1949, "CardiB": 1992}))
#3
In this way, the number of elements has been taken.
fin
Python #Hello World for super beginners
Python for super beginners and super beginners # Easy to get confused
Python #type (type) and how to check type (type) for super beginners of Python
How to convert Python # type for Python super beginners: str edition
How to convert Python # type for Python super beginners: int, float edition
Read Python # .txt file for super beginners in Python with working .py
Python #Function 1 for Python Super Beginners
Python #Function 2 for super beginners of Python
Recommended Posts