mirror of
https://github.com/asciinema/asciinema.git
synced 2026-04-26 00:15:56 +03:00
[GH-ISSUE #291] "PYTHON" UnboundLocalError: local variable 'a' referenced before assignment #196
Labels
No labels
bug
compatibility
feature request
fit for beginners
help wanted
hosting
idea
improvement
packaging
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/asciinema#196
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @AchailletBadigra on GitHub (Apr 6, 2018).
Original GitHub issue: https://github.com/asciinema/asciinema/issues/291
can anyone help me to fund the mistake inside my code please i have this error every time i try to execute the code searching part(4-search a book)
import time;
import pickle
localtime=time.asctime(time.localtime(time.time()))
bks=[]#-bks contain a list of books
bksid=[]#bksid contain a list of books identifiant
bksisn=[]#bksisn contain a list of international serial number
bksschl=[]#bksschl contain a list of school name
bkssts=[]#bkssts contain a list of books status
bksauthors=[]#bksauthors contain a list of books author
Return=[]#Return contain a list of Return books
brwname=[]#brwname contain a list of student name who have borrowed a books
brwsrn=[]#brwsrn contain a list of student serial number who have borrowed a books
belier=[]
def add_bks():
def borrow_bks():
print("borrow a book");
print("Borrowing date and heure:",localtime)
brwsnbook=int(input("Enter book serial number:\n"))
key1=brwsnbook
for i in range(len(bksisn)):
if key1==bksisn[i]:
pos1=(i)
for j in range(len(bkssts)):
if pos1==j:
sts=(bkssts[j])
if sts=="na":
print("The book is not there")
else:
name=str(input("Enter student name:\n"))
brwname.append(name)
srn=str(input("Enter student SRN:\n"))
brwsrn.append(srn)
for j in range(len(bkssts)):
pos1==j
bkssts[j]="na"
def Return_bks():
print("Return a book")
print("Returning date and heure:",localtime)
rtrsnbook=int(input("Enter book serial number:\n"))
key2=rtrsnbook
for i in range(len(bksisn)):
if key2==bksisn[i]:
pos2=(i)
for j in range(len(bkssts)):
if pos2==(j):
bkssts[j]="a"
tres=open("libra.txt","ab+")
pickle.dump(bks,tres)
pickle.dump(bksid,tres)
pickle.dump(bksisn,tres)
pickle.dump(bksschl,tres)
pickle.dump(bkssts,tres)
pickle.dump(bksauthors,tres)
tres.close()
tres=open("libra.txt","rb+")
bks1=pickle.load(tres)
bksid1=pickle.load(tres)
bksisn1=pickle.load(tres)
bksschl1=pickle.load(tres)
bkssts1=pickle.load(tres)
bksauthors1=pickle.load(tres)
tres.close()
def Menu():
print("\nLibrary menu options*\n",)
print(" 1-Add a book\n",
"2-Borrow a book\n",
"3-Return a book\n",
"4-Search a book")
def search_bks():
def choice():
Menu()
ans=input("Do you want to select any option?:\n")
while (ans=="y"):
ch=int(input("Enter your choice please:\n"))
if ch==1:
add_bks()
if ch==2:
borrow_bks()
if ch==3:
Return_bks()
if ch==4:
search_bks()
ans=input("do you want to select any other option?:\n")
if ans=="n":
print("Thank you")
choice()