+ 1
Why no output not error?
If I add â:â between âprintâ and â()â , shouldnât it be an error? However it only shows âno outputâ, why? code print:(1) result no output Thanks a lot~
6 RĂ©ponses
0
Why did you add the colon? What are you trying to do and the reason behind it?
+ 4
I understand you expected a syntax error, but want to know why it didn't happen.
The colon has no meaning, but it splits "print" and its argument 1. Then, Python returns both values as they are: a function reference and a number. Python allows values to be stated, but does nothing to them. So, no output.
It would be interesting for you to run this line on a Python prompt, and see it output the function reference and the number.
But I still don't know why the colon didn't raise an error. Maybe it's just a valid symbol, without action in this context.
+ 3
Hi Ramee ,
i guess it is not about print() function anymore. So it doesn't give any error.
For example try something you made up like:
var:(2) or srl76:(5) and run. Same behaviour, no error, no output. Maybe they are so meaningless for Python, so nothing occurs even an error. But Interesting to know. Thanks for sharing.
0
The â:â is not added in purpose, it is a mistake by my student, and he My asked me why it is not an error?
0
https://code.sololearn.com/cYLfg7E68NP8/?ref=app
Here's some code and i ask again though, why? It's not correct, no reason to do it.
0
You did not insert the colon