Why and when is colon used in program | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why and when is colon used in program

If question

17th May 2019, 3:09 PM
Sameer
15 Answers
+ 1
if 3>2: print 3 else : print 2
17th May 2019, 3:18 PM
Basel.Al_hajeri?.MBH()
Basel.Al_hajeri?.MBH() - avatar
+ 1
Read python course.It is so helpful😉
17th May 2019, 3:20 PM
Basel.Al_hajeri?.MBH()
Basel.Al_hajeri?.MBH() - avatar
+ 1
Does it work like ; in C++
17th May 2019, 3:20 PM
Sameer
+ 1
Nope Sameer
17th May 2019, 3:21 PM
Basel.Al_hajeri?.MBH()
Basel.Al_hajeri?.MBH() - avatar
+ 1
Thanks
17th May 2019, 3:22 PM
Sameer
+ 1
if(3>2) cout <<3; // the space before the cout is not important else // we don't use : after if or else cout <<2; //
17th May 2019, 3:22 PM
Basel.Al_hajeri?.MBH()
Basel.Al_hajeri?.MBH() - avatar
+ 1
The writing is different ,but the idea and way same.
17th May 2019, 3:24 PM
Basel.Al_hajeri?.MBH()
Basel.Al_hajeri?.MBH() - avatar
+ 1
So in print() colon is not required
17th May 2019, 3:24 PM
Sameer
+ 1
You can say print() like cout in c++
17th May 2019, 3:25 PM
Basel.Al_hajeri?.MBH()
Basel.Al_hajeri?.MBH() - avatar
+ 1
Most welcome Sameer
17th May 2019, 3:26 PM
Basel.Al_hajeri?.MBH()
Basel.Al_hajeri?.MBH() - avatar
+ 1
No I meant after print("abc") colon is not required
17th May 2019, 3:26 PM
Sameer
+ 1
Yes the colon after the print is not required
17th May 2019, 3:32 PM
Basel.Al_hajeri?.MBH()
Basel.Al_hajeri?.MBH() - avatar
+ 1
Ok thanks
17th May 2019, 3:32 PM
Sameer
+ 1
Welcome ask here as you like brother we are brothers 😉😉
17th May 2019, 3:34 PM
Basel.Al_hajeri?.MBH()
Basel.Al_hajeri?.MBH() - avatar