+ 11
Can anybody explain me the line of code pls.
what is happening here while declaring the function checkio? ``` def checkio(text: str) -> str: ```
11 Antworten
+ 12
It's basically the same as def checkio(text).
"text: str" means that the parameter "text" is expected to be of type str, "-> str" means that the return value of the function is also a string. This is more or less just an information for the user or other programmers. The interpreter just ignores these statements and even if you call the function with an integer parameter or let it return a boolean (or nothing at all), there won't be any warning or error message.
+ 8
https://www.python.org/dev/peps/pep-3107/
https://code.tutsplus.com/tutorials/python-3-function-annotations--cms-25689
+ 5
It implies that the function will return a string value. But, like I said, if it actually returns an integer or something else doesn't make any difference. It's just an annotation so that other programmers know what kind of return value they can expect from the function ☺️
+ 2
create a function called checkio.
The function accepts a parameter of type str (iirc if it isn't it will convert if possible) and returns a str
+ 2
You're basically annotating.
+ 2
Thanks all of you
+ 1
Q to Anna,
Does ->str also means that return str or just referring return type has to be str?
Hope you understand what i am saying
+ 1
Thanks Anna👏
+ 1
You are telling python which type you expect parameter to be and also what type of data you will return.
- 1
I'm not do anything but I'm faster a boy
- 1
My real lover is python programming