# How can i subtract more than 2 numbers which i have accepted from user:

Eg:Suppose i got input numbers as 20,3,5,7 from user. So i want to do 20-3-5-7 and as output i should get the ans as 20-3-5-7=5.(I can get as many numbers as user want for subtraction)

10/14/2020 4:51:08 PM

PRATHIK5 Answers

New Answernums = ["20","3","5","7"] #numbers = input().split(",") expr = '-'.join(nums) print(f"{expr}={eval(expr)}") https://code.sololearn.com/czjGhiPTTIJw/?ref=app

Please show us your attempt here. If you have not done a real try by yourself first, please do this and then come back. But i will give you some hints: - take some numbers as input. use input() function, give all numbers in one line, separated by comma or space - split this input according the separator used at the input - all input will be returned as string from input funtion. as you want to calculate with the numbers, you have to convert them from str to int - using split creates a list with all input numbers as integers - use a variable that will hold the current value of calculation - to calculate, you need to use a for loop iterating over ste list of numbers, that gives you one item per iteration - use the items from the for loop and calculate it with the variable - if iteration of for loop is finished, you will have the requested result.

PRATHIK , i saw your code about a Bill Calculator an Sum of Odd and Even numbers. you have used there all the stuff you need for this task. Give it a try!