+ 21

In this case, float 7.0 is an integer - why not multiply it with it ¿?

https://code.sololearn.com/cQf99P0WJpQd/?ref=app

19th Feb 2018, 8:48 PM
Vučko/Вучко/Vuchko
Vučko/Вучко/Vuchko - avatar
3 Antworten
+ 20
Thanks Jakob Marley !¡ Хвала Jakob Marley !¡
19th Feb 2018, 9:35 PM
Vučko/Вучко/Vuchko
Vučko/Вучко/Vuchko - avatar
+ 10
To sum it up, you can't multiply a string by an float in Python. When you multiply the string by an int, you're basically just telling it how many times to print that string. When you try to use a float, it's considering it actual math and math doesn't like calculating with strings. Why it does it with a float is because you can't print a string 7.2 times, you either print it X times or you don't, it's not a gray area type of deal.
19th Feb 2018, 8:53 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 6
Multiplying a list is defined for a list and an integer. It is clear for print("4" +2) The operator + is not defined for string and int. The syntaxchecker sees a list and a float. --> Error Error Error and before you can discuss with it (--> hey come on ! 7.0 is 7) ... it has stopped all work and wont listen and even not discuss with you Sure it sounds a bit hardhearted, but actually the interpreter feels a an educational mission for coder.
20th Feb 2018, 7:55 PM
Oma Falk
Oma Falk - avatar