a=(3+5,) print(a*2).....The output is (8,8) How it come. | Sololearn: Learn to code for FREE!

+1

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

Please explain

.

7/25/2021 3:47:11 AM

Rajulapudi Aswini

4 Answers

New Answer

+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)

+1

thanks NotAPythonNinja πŸ˜‡

+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

0

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)