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

new to python having trouble printing 4 variables

adding = int(5+3)
subtract = int(10-2)
multiplication = int(2*4)
division = int(16/2)
print (str(adding,"\n",subtract,"\n",multiplication,"\n",division))

im getting a typeError: TypeError: str() takes at most 3 arguments (7 given)

>Solution :

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:
Just change this piece of code from this

print (str(adding,"\n",subtract,"\n",multiplication,"\n",division))

To this.

print (adding,"\n",subtract,"\n",multiplication,"\n",division)

Reason: str() is a typecast method. You don’t need to typecast each and everything.

For Reference:
https://www.geeksforgeeks.org/type-casting-in-python-implicit-and-explicit-with-examples/

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