campusx-official / dsmp-2022-23

All the codes and tasks taught in the CampusX Data Science Mentorship Program 2022-23
7 stars 1 forks source link

Getting error while using print() #2

Open Sayan-Roy-729 opened 1 year ago

Sayan-Roy-729 commented 1 year ago

If I declare 3 numbers(integer variables) let's say a,b,c, and give them some values. Then if I print them by the syntax print(a,'\n', b, '\n', c) it works and I get output in different lines. But with one space so I tried to use the syntax "print(a '\n' b '\n' c)" but it didn't work and I got error what is the issue?

samp-suman commented 1 year ago

print(a '\n' b '\n' c) In above code there is Syntax error. Comma is missing.

print(a,'\n', b, '\n', c) #This is correct syntax to print value of a, b and c in three different lines.

If you want to print value of a, b and c separated by space write print(a, b, c)