+ 1

a=(3+5,) print(a*2).....The output is (8,8) How it come.

Please explain

25th Jul 2021, 3:47 AM
Rajulapudi Aswini
Rajulapudi Aswini - avatar
4 Antworten
+ 4
This code should explain it all. (When you multiply a string by an integer, Python returns a new string. This new string is the original string, repeated X number of times (where X is the value of the integer)) Same applies to set, list in python. [CODE] # tuples a=(3+5,) print(a) print(a*2) print(a*3) print(a*4) # string print("understood "*3) # list l = [1,2,3] print(l*2)
25th Jul 2021, 3:50 AM
minirkk
minirkk - avatar
+ 1
thanks NotAPythonNinja 😇
25th Jul 2021, 6:24 AM
minirkk
minirkk - avatar
+ 1
Rajulapudi Aswini, As a future reference, next time please, don't forget to use proper tags in your question 👍 https://code.sololearn.com/W3uiji9X28C1/?ref=app
25th Jul 2021, 6:36 AM
Ipang
+ 1
variable a is a tuple, then we multiply tuple by 2 and our result -tuple (8,8)🙂 it’s the same if we (8,) +(8,) result will be (8,8)
26th Jul 2021, 6:55 PM
chak88