How to add values in a single tuple in python -
i newbie in python. so, have doubt code :
a = 1 b = 2 c = 4,5 d = (a,b,c) print d
when run this, got output :
> (1, 2, (4, 5))
but expected output :
> (1,2,4,5)
how can expected output? can u give me solution without importing packages?
it not duplicate of question because need based on single variable no need list.
thanks in advance
c
4,5
i.e. tuple
.
you need :
a = 1 b = 2 c = 4,5 d = (a, b) + c # add elements of tuple c tuple (a,b) print(d)
this result in :
(1, 2, 4, 5)
Comments
Post a Comment