-1

When I try to run this code

print("What is the mass?")
m = input()
c = 3.00 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10
e = m * c ** 2
print(e)

But it gives me this error

Traceback (most recent call last):
File "/Users/Abood/Desktop/E = MC2.py", line 4, in <module>
e = m * c ** 2
TypeError: can't multiply sequence by non-int of type 'float'

I also tried other solutions but it still did not work!

Terry Jan Reedy
  • 17,284
  • 1
  • 38
  • 50
Eletrix
  • 63
  • 1
  • 8

1 Answers1

1

Try this :

m = float(input())

The default type for input() is string.

You need to cast the input string to float type and then multiply.

Underoos
  • 3,734
  • 6
  • 30
  • 63
Arkistarvh Kltzuonstev
  • 6,572
  • 7
  • 24
  • 47