0

Why show different answer? Please help

X="gjsgd","gjjsf" print (X) print ("gjsgd","gjjsf")

9th Feb 2024, 8:05 AM
Nikhil Yadav
Nikhil Yadav - avatar
3 Antworten
+ 6
X is a tuple. X = "gjsgd","gjjsf" is the same as X = ("gjsgd","gjjsf") that is why print(X) is ("gjsgd","gjjsf") if you want gjsgd gjjsf use print(*X) then it will print gjsgd gjjsf or print(X[0], X[1]) will also print gjsgd gjjsf
9th Feb 2024, 9:37 AM
Bob_Li
Bob_Li - avatar
+ 5
print function accepts different argument. for the first print X will be a single argument so it prints as tuple for the second print there are two different argument which will be print with space. If you put comma in print it means values will be print with space.
9th Feb 2024, 9:36 AM
A͢J
A͢J - avatar
+ 1
Nikhil Yadav , It's already answered, but here a some tips. X should be x, since it's not a class name. You don't need @ in tags. The language is python, not phyton.
9th Feb 2024, 8:39 PM
Rain
Rain - avatar