Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

TypeError: can't multiply sequence by non-int of type 'tuple' mean?

a = (1,2)
b = (3,4)

plus = a + b
multi = a * 2
multi2 = a * b

print(plus) 
print(multi) 
print(multi2) 

terminal

 multi2 = int(a * b)
TypeError: can't multiply sequence by non-int of type 'tuple'

I don’t know why it’s not working…
Can’t I use multi2?

ps. I used a translator.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

change this line :

multi2 = a * b

to :

multi2 = tuple(l * r for l, r in zip(a, b))

The simplest way to multiply two tuple.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading