+ 1

# Help

numbers = int(input()) #(2+4) = 6 print(numbers) >>> numbers = int(input()) ValueError: invalid literal for int() with base 10: '(2+4)' lst = [(2+4),(5*2),(6-5)] for i in lst: print(i) >>> 6 10 1

3 Answers

+ 6

CodeStory
Take input as string and remove first and last bracket.
Then use loop and eval function to calculate like this:
numbers = input() #(2+4) = 6
print(numbers)
list1 = (numbers[1:-1]).split(',')
for k in list1:
print (eval(k))

+ 4

CodeStory
[(2+4) is a not an integer value so you cannot cast with int.

+ 2

Thank you very much, good luck to you!! 👍👍👍