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

If a '-' contain in int input it will print something

well what im trying to do its when you input a "-Number"
it will print something

and this the error im getting:

Traceback (most recent call last): File "main.py", line 10, in

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

if "-" in use: TypeError: argument of type ‘int’ is not iterable

this is my code

n1 = 800
use = []
use2 = []

while use != n1:
  use = int(input("Money: "))
  use2.append(use)
  print("The money that left:",800 - sum(use2))

  if "-" in use:
    print('ok')

>Solution :

n1 = 800
use = []
use2 = []

while use != n1:
  use = input("Money: ")
  use2.append(int(use))
  print("The money that left:",800 - sum(use2))

  if "-" in use:
    print('ok')

Worked for me!

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