"2" + "2" | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

"2" + "2"

If I use Powershell and let it run unther python then I can write "2" + "2" and get 22. two strings added; perfect. But if I use an editor and write the same and let it run as a pythonprogram in the commandline then I get an error. Does somebody know why? the Pythonprogramm to write a script and write there "2" + "2" then I get 22. Everything good :D but if I write the same in a editor and let after this as a pythoncode run, then I get a error. Why?

29th Apr 2020, 10:53 PM
Sur Tur
Sur Tur - avatar
4 Answers
+ 6
I think if you're making a code file, you need to explicitly tell it that you want to print the value. A command line will automatically print.
29th Apr 2020, 11:34 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 4
I think I understand now. If I write in an interpreter "2" + "2" then the computer understand it direct and if I write just a program with "2" + "2" and save this script with test.py then the program have not enough information. You think this is it?
29th Apr 2020, 11:31 PM
Sur Tur
Sur Tur - avatar
+ 3
Show your full code. Then maybe we can find somewhere else that the code messes up.
29th Apr 2020, 11:06 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
0
thanks :D
30th Apr 2020, 12:03 AM
Sur Tur
Sur Tur - avatar