Syntax Error at the end of a while loop

2024/7/7 6:01:56

EDIT: This question was ask at the start of my learning process for python. The Syntax Error was produced by pythons IDLE with no trackback to speak of. This was the main cause of the problem and confusion when people asked for the full error.

I am working on a simple note recall program. I am not 100% sure why I keep getting a syntax error if anyone can assist.

Note: The error was only "Syntax Error". There was no other information displayed with the error.

The error is showing up at the end of the program code where program = False is. Am I not allowed to put that after print or something?

Keep in mind I am very new to Python and programming in general. So if you do have a solution please explain what I was doing wrong.

####################################################################################
''' Goal = quick access list of notes that I can add to or remove from as needed.'''
'''    Note: this script is designed for python 3.2+ check converted elements    '''
####################################################################################notes = {'ban': 'BAN: is the account number.','bdt': 'testing    derp'}program = True
active = Falsedef note_finder(word):while active == True:print ('Type one of the following keywords','\n','ban','\n','test','\n','test2','\n', 'Or type exit to close')choice2 = input('--> ').lower()if choice2 == 'exit':print ('Exiting Function')active = Falseprogram = Trueelif choice2 in notes:print (notes[choice2])else:print ("Not a Keyword")while program == True:print ('Type one of the following options:','\n','1','\n','2','\n','3')choice1 = int(input('--> '))if choice1 < 1 or choice1 > 3:print ("Not an option")else:print (note_finder(input('--->'))program = Falseactive = True
Answer

You're missing a parenthesis at the end of the print line.

YOU HAVE:

 print (note_finder(input('--->'))

IT SHOULD BE:

else:print (note_finder(input('--->')))program = Falseactive = True
https://en.xdnf.cn/q/119645.html

Related Q&A

Creating an adjacency list class in Python

I was wondering how to create an adjacency list class Here is what I have so far:class AdjNode:def __init__(self, value):self.vertex = valueself.next = Noneclass Graph:def __init__(self):# Add edgesdef…

How can I separate a rust library and the pyo3 exported python extensions which wrap it

I have a rust library which provides useful functionality for use in other rust programs. Additionally I would like to provide this functionality as a python extension (using pyo3 and setuptools-rust, …

how do I count unique words of text files in specific directory with Python? [closed]

Its difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying thi…

Python convert path to dict

I have a list of paths that need to be converted to a dict ["/company/accounts/account1/accountId=11111","/company/accounts/account1/accountName=testacc","/company/accounts/acc…

Python: How to download images with the URLs in the excel and replace the URLs with the pictures?

As shown in the below picture,theres an excel sheet and about 2,000 URLs of cover images in the F column. What I want to do is that downloading the pictures with the URLs and replace the URL with the…

I cant figure out pip tensorrt line 17 error

I couldnt install it in any way, I wonder what could be the cause of the error. I installed C++ and other necessary stuff I am using windows 11 I installed pip install nvidia-pyindex with no problem. S…

Extracting specific values for a header in different lines using regex

I have text string which has multiple lines and each line has mix of characters/numbers and spaces etc. Here is how a couple lines look like:WEIGHT VOLUME CHA…

Creating a function to process through a .txt file of student grades

Can someone help...My driver file is here:from functions import process_marks def main():try:f = open(argv[1])except FileNotFoundError:print("\nFile ", argv[1], "is not available")e…

Python Reddit PRAW get top week. How to change limit?

I have been familiarising myself with PRAW for reddit. I am trying to get the top x posts for the week, however I am having trouble changing the limit for the "top" method. The documentatio…

I want to convert string 1F to hex 1F in Python, what should I do?

num="1F" nm="1" nm1="2" hex(num)^hex(nm)^hex(nm1)I wrote it like the code above, but hex doesnt work properly. I want to convert the string to hexadecimal, and I want an x…