0
Int with comma or semicolon
Hi! I was searching online but the results were not satisfactory. I'm trying to understand what is meant by the below, in relation to the comma and the semicolon: x=3, y=5; Can anybody throw a rope here? Thanks!
3 Respostas
+ 1
x = 3, is equal to x = (3,)
Here you create a tuple with a single element instead of an int.
About semicolons:
Don't end your lines with one in Python, it's not needed.
Only use it when you want to write two statements in one line:
a = 1; b = 2
0
doesnt python allow us to drop semicolon/coma at the end?
but for other language(java,c++),using coma help u to write shorter syntax fot declaring variable cause u dont have to specify the type for each var
using semicolon
int x = 5;int y = 6;
using coma
int x = 5,y = 6;