+ 3

Type of variable

Why does print automatically not get strongly type d when adding integers in Python 3?

27th Feb 2021, 10:25 AM
Sanjay Kamath
Sanjay Kamath - avatar
8 Réponses
- 1
I don't understand your question.
27th Feb 2021, 11:01 AM
Théophile
Théophile - avatar
+ 3
did you want to know why "string"+number is not allowed in print statements? because in python, you can only concatenate string to string, no implicit casting is done... so you either require: print("string"+str(number)) or: print("string",number,sep="") ... or others string formatting ways (old and new string formats)
27th Feb 2021, 12:12 PM
visph
visph - avatar
+ 2
@visph I don't think it is a good feature 💻
27th Feb 2021, 1:27 PM
Sanjay Kamath
Sanjay Kamath - avatar
+ 2
Théophile that would be perfect if best answer mark was not misused ^^ but it seems that OP don't like the "feature" explained in my answer and prefer finally set your answer as best :(
27th Feb 2021, 2:27 PM
visph
visph - avatar
+ 1
that's not the question. it is as it is designed... mail guido about it if you want, but discuss here would not change it ^^
27th Feb 2021, 1:29 PM
visph
visph - avatar
+ 1
and marking best answer the one wich tell you he doesn't understand your question is not fair... mark none if you (really) want, but don't mark not useful answers ^^
27th Feb 2021, 1:31 PM
visph
visph - avatar
0
I actually still don't understand his question : "why does print doesn't automatically get strongly typed when adding integers" It doesn't mean anything 🤷‍♂️ And I can't find the link with addition between strings and integers 🙄 But anyway, if the visph's answer answers his question, that's perfect.
27th Feb 2021, 2:23 PM
Théophile
Théophile - avatar
0
visph I agree that it is not fair, since I couldn't provide an answer. I hope that he will mark your answer as best, or at least, as you said, "unmark" my answer. If he doesn't like the fact that python is strongly typed, he can try another langage 😁
27th Feb 2021, 2:30 PM
Théophile
Théophile - avatar