+ 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~

26th Dec 2021, 12:54 PM
Ramee
6 Respuestas
0
Why did you add the colon? What are you trying to do and the reason behind it?
26th Dec 2021, 1:00 PM
Slick
Slick - avatar
+ 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.
26th Dec 2021, 5:01 PM
Emerson Prado
Emerson Prado - avatar
+ 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.
26th Dec 2021, 4:22 PM
SoloilSole
SoloilSole - avatar
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?
26th Dec 2021, 1:09 PM
Ramee
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.
26th Dec 2021, 1:18 PM
Slick
Slick - avatar
0
You did not insert the colon
28th Dec 2021, 1:01 AM
Sivalingam Varmith
Sivalingam Varmith - avatar