0

Function argument type in python

Hi Refer code below: It has one method which has arg of type int. Why it allows string to be passed as argument If argument type cannot be provided, why it works with :int in function parenthesis https://sololearn.com/compiler-playground/c1cKyanINc7h/?ref=app

6th Oct 2024, 12:46 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
3 Respostas
+ 4
type annotation is documentation – NOT type checking
6th Oct 2024, 12:47 PM
Lisa
Lisa - avatar
+ 3
Also, Sololearn is not an ide. A proper ide would give you warnings, or little red squiggly lines. But yes, it will still be evaluated . Python is dynamically typed. Type annotations is just a way to enable your ide to remind you of the expected types you previously assigned to the variables in your code.
6th Oct 2024, 1:00 PM
Bob_Li
Bob_Li - avatar
+ 1
Thanks Lisa nd Bob_Li
7th Oct 2024, 10:57 AM
Ketan Lalcheta
Ketan Lalcheta - avatar