0

What's wrong with my code?

I want to test out every function i learned in Python in one file. But it took time for me to do test another function so I need a program that waits for user to input their choice for each function. 1 for append() 2 for index() 3 for... Etc I tried alot, but it says: syntax error at line 57. https://code.sololearn.com/cx0H19WzuUaF/?ref=app

25th Sep 2022, 2:06 PM
Dragon RB
Dragon RB - avatar
19 Answers
+ 3
you did not close the print parenthesis above line 57. there are also indentation error and variable naming errors after that, but I'm sure you can fix them.
25th Sep 2022, 2:50 PM
Bob_Li
Bob_Li - avatar
+ 2
Azhagesan \" (🌼), thank you. It works! I don't know how to mention your account name, soo....
25th Sep 2022, 2:56 PM
Dragon RB
Dragon RB - avatar
+ 1
Line 56 ')' missing Line 67 i change elif to if it worked for me is that your expected output https://code.sololearn.com/c5p1KAyce19Z/?ref=app
25th Sep 2022, 2:20 PM
Azhagesanヾ(✿)
Azhagesanヾ(✿) - avatar
+ 1
Line 56 ')' missing Line 67 elif has to be in the same line as if condition But the code still failing in the option 3 https://code.sololearn.com/cE0ToMhMBsWp/?ref=app
25th Sep 2022, 9:28 PM
SteephenL
SteephenL - avatar
+ 1
Bob_Li I use Pydroid for my code. Because I don't have a computer. I hope I'll have one someday..
26th Sep 2022, 2:28 AM
Dragon RB
Dragon RB - avatar
+ 1
I solved your error, do you want it right now???
26th Sep 2022, 3:39 PM
AYUSHMAAN SINGH
+ 1
I found you have 12 errors. Have you ever bothered to check the code when writing the code? print('''Please choose a function. 1 --------------> append() 2 --------------> index() 3 --------------> count(), reverse, remove 4 --------------> join()''') userinput = int(input()) if userinput == 1: print("********************append() FUNCTION*****************") num = [5,4,3,2,1] num.append(6) print(len(num)) if userinput == 2: print("********************index() FUNTION*****************") numl = [5,3,1,3] print(numl.index(5)) sentences = ["Hi", "Python", "!"] print("********************index() FUNCTION(WORD)*****************") print(sentences.index("Python")) number = [3,5,7,9,11,13,19,50] #debug 1 if userinput == 3: print("********************count() FUNCTION*****************") print("Please enter 5 numbers to continue.") usinput = int(input()) 👇
26th Sep 2022, 9:28 PM
Solo
Solo - avatar
+ 1
usinput2 = int(input()) usinput3 = int(input()) usinput4 = int(input()) usinput5 = int(input()) number = [usinput, usinput2, usinput3, usinput4, usinput5] print("Make sure you have enter atleast 2 duplicate numbers. now input a number that you want the program to find ") usinput6 = int(input()) print("Appeared:") print(number.count(usinput6)) print("times") print("********************reverse() FUNCTION*****************") print('''Do you want to reverse your number list? 1 ----------> Yes 2 ----------> No''') usinput7 = int(input()) if usinput7 == 1: #debug 2 print("Reversed version or your number list:") number.reverse() print(number) if usinput7 == 2: #debug 3 print("Alright.") elif usinput7 != 2 or usinput7 != 1: #debug 4, 5 while False: #debug 6 print("That is not in the option.") 👇
26th Sep 2022, 9:38 PM
Solo
Solo - avatar
+ 1
usinput8 = int(input()) if usinput8 == 2 or usinput8 == 1: break if True: #debug 7? print("********************remove() FUNCTION*****************") print('''Do you want to remove a number from your list? 1 ------------> Yes 2 ------------> No''') #debug 8 usinput9 = int(input()) if usinput9 == 1: print("Now, let\'s remove a number from your number list that you input.") print("What number do you prefer to remove(In your input)?") usinput = int(input()) number.remove(usinput) print("Done, here is your list:") print(number) if usinput9 == 2 and usinput9 != 1: #debug 9 print("Alright.") elif (usinput9 != 2) or (usinput != 1): #debug 10 while False: #debug 11 print("That is not in the option.") 👇
26th Sep 2022, 9:39 PM
Solo
Solo - avatar
+ 1
if usinput == 2 or usinput == 1: break if usinput9 == 2: #debug 12 print("Here is your number list:") print(number) if userinput == 4: print("\t .join() FUNCTION") print("*****************************************************") num = ",".join(["Hello", "there"]) print(num) I have not tested your code, there may be many more errors. 😱
26th Sep 2022, 9:44 PM
Solo
Solo - avatar
0
Python is kinda annoying because it doesn't use curly brackets {} for command like if, else, it uses colon instead
25th Sep 2022, 2:09 PM
Dragon RB
Dragon RB - avatar
0
Bob_Li, thank you for your answer! I appreciate your work for finding my mistake.
25th Sep 2022, 3:08 PM
Dragon RB
Dragon RB - avatar
0
Dragon RB I am sure you are not using Sololearn playground to test your code, since you are interactively taking user input and displaying messages. What ide are you using? an unclosed parenthesis should have been easy to catch... to mention another user type @ and a popup box of people who replied to you should appear, then you can click the name of the person.
25th Sep 2022, 3:17 PM
Bob_Li
Bob_Li - avatar
0
Bob_Li Alright.
26th Sep 2022, 2:25 AM
Dragon RB
Dragon RB - avatar
0
Dragon RB you should. There are a lot more things you can do in a pc or laptop. Pydroid always creates a closed pair of parenthesis, square brackets, braces, apostrophe, etc. Maybe you just erased the closing part accidentally.
26th Sep 2022, 2:51 AM
Bob_Li
Bob_Li - avatar
0
Hii there, It's good that you mentioned every single thing but your code has a lot of issues (indention, variable, parentheses) so it is good that you check your code step by step. And you are using pydroid right!! So at there you can practice it step by step and then add in a whole code. I will also try to solve all the problem but it is good that you solve them out, so you can learn where you mistaken. And I hope that you definitely will solve the problem...... Thanks
26th Sep 2022, 3:13 PM
AYUSHMAAN SINGH
0
AYUSHMAAN SINGH Yes, I'd like to.
26th Sep 2022, 4:08 PM
Dragon RB
Dragon RB - avatar
0
https://code.sololearn.com/cT8dGkjIJ678/?ref=app There were two mistakes in this code: 1. on line 56: a closing parenthesis was expected but it was missing. 2. on line 67: the rules of IF...ELIF...ELSE... statement were not followed as an elif statement comes after if. But it should work now if u use the code below!
27th Sep 2022, 2:24 PM
Altair Enigma
Altair Enigma - avatar
1
SteephenL Don't worry. I fixed that.
26th Sep 2022, 4:46 AM
Dragon RB
Dragon RB - avatar