+ 2

syntax error in line "54"

File "./Playground/file0.py", line 54 elif operation=="multiply": ^ SyntaxError: invalid syntax clink on this link to see this code i have posted this question earlier i also made certain changes but it seems that i am stuck and cannot get out of this on my own please someone tell me what to do with explaination please clink on this link to see my code::: https://code.sololearn.com/caHEhm1MDHc6/#py

14th Aug 2020, 8:48 AM
Tayyib
Tayyib - avatar
4 Respuestas
+ 5
Tayyib , here are some lines of code, how to make a simple calculator. I am sure you can use this principle also for your calculator. input 1: operator input2: sequence of numbers separated by space to get all numbers needed in one run. so input is only done once for all different operations. also output is only given once at the end of the code. operation = input() numbers = map(int, input().split()) # input can be <5> <or> <3 5 or 3 5 2 9 7 ...> if operation == "add": result = sum(numbers) elif operation == 'sub': result = numbers[0] - numbers[1] # .... print(f'result of {operation} = {result}')
14th Aug 2020, 5:09 PM
Lothar
Lothar - avatar
+ 4
line 53 is not correct. print("Sum of all elements in given list: " + max(total)) you can not call total with function max(), as total is an integer, but should be an iterable. and you can not 'add' a string + a numerical value. You have put a lot of effort to your code. Really nice! But let me give you a friendly hint. You should try to rework the code. before starting you should spend some time to think about, what you can improve / make simpler, then start with only data input and function 'add' (but keeping in mind the other functions) c later you can add other functions. happy coding!
14th Aug 2020, 3:22 PM
Lothar
Lothar - avatar
+ 2
thank you i am very happy to see such kind of a support just for an error like you all!!!!! may GOD bless you with happiness and knowledge #keep learning
15th Aug 2020, 4:48 PM
Tayyib
Tayyib - avatar
+ 1
Look at the print statement above at line 53 ,you are missing a closing parenthesis
14th Aug 2020, 8:58 AM
Abhay
Abhay - avatar