Solved – can’t multiply sequence by non-int of type ‘float’

In this article, you will learn how to solve can’t multiply sequence by non-int of type ‘float’ error in Python. Let’s look at a code example…

The post Solved – can’t multiply sequence by non-int of type ‘float’ appeared first on CodeSource.io.


This content originally appeared on CodeSource.io and was authored by Deven

In this article, you will learn how to solve can’t multiply sequence by non-int of type ‘float’ error in Python.

Let’s look at a code example that produces the same error.

spend = input("How much did you spend? ")
discount = 0.22
money_left = spend - (spend * discount)
print(round(money_left, 2))

output

How much did you spend? 100
Traceback (most recent call last):
  File "<string>", line 3, in <module>
TypeError: can't multiply sequence by non-int of type 'float'

In order to solve solve can’t multiply sequence by non-int of type ‘float’ error in Python we use the We use the float() method like in the code snippet below:

spend = float(input("How much did you spend? "))
discount = 0.22
money_left = spend - (spend * discount)
print(round(money_left, 2))

Output

How much did you spend? 100
78.0

The post Solved – can’t multiply sequence by non-int of type ‘float’ appeared first on CodeSource.io.


This content originally appeared on CodeSource.io and was authored by Deven


Print Share Comment Cite Upload Translate Updates
APA

Deven | Sciencx (2021-03-11T05:56:23+00:00) Solved – can’t multiply sequence by non-int of type ‘float’. Retrieved from https://www.scien.cx/2021/03/11/solved-cant-multiply-sequence-by-non-int-of-type-float/

MLA
" » Solved – can’t multiply sequence by non-int of type ‘float’." Deven | Sciencx - Thursday March 11, 2021, https://www.scien.cx/2021/03/11/solved-cant-multiply-sequence-by-non-int-of-type-float/
HARVARD
Deven | Sciencx Thursday March 11, 2021 » Solved – can’t multiply sequence by non-int of type ‘float’., viewed ,<https://www.scien.cx/2021/03/11/solved-cant-multiply-sequence-by-non-int-of-type-float/>
VANCOUVER
Deven | Sciencx - » Solved – can’t multiply sequence by non-int of type ‘float’. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/03/11/solved-cant-multiply-sequence-by-non-int-of-type-float/
CHICAGO
" » Solved – can’t multiply sequence by non-int of type ‘float’." Deven | Sciencx - Accessed . https://www.scien.cx/2021/03/11/solved-cant-multiply-sequence-by-non-int-of-type-float/
IEEE
" » Solved – can’t multiply sequence by non-int of type ‘float’." Deven | Sciencx [Online]. Available: https://www.scien.cx/2021/03/11/solved-cant-multiply-sequence-by-non-int-of-type-float/. [Accessed: ]
rf:citation
» Solved – can’t multiply sequence by non-int of type ‘float’ | Deven | Sciencx | https://www.scien.cx/2021/03/11/solved-cant-multiply-sequence-by-non-int-of-type-float/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.