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!

14th Apr 2020, 11:50 AM
Salvatore Junior Iaccarino
Salvatore Junior Iaccarino - avatar
3 Antworten
+ 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
14th Apr 2020, 12:08 PM
HonFu
HonFu - avatar
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;
14th Apr 2020, 11:56 AM
durian
durian - avatar
0
Thank you very much Lily Mea and HonFu!
14th Apr 2020, 12:25 PM
Salvatore Junior Iaccarino
Salvatore Junior Iaccarino - avatar