0

Functions in python What is the error in the code?simple library implementation code

members = [] books = [] borrowed = {} ADD_MEMBER = 1 DELETE_MEMBER = 2 ADD_BOOK = 3 DELETE_BOOK = 4 FIND_BORROWER = 5 ISSUE_BOOK = 6 RETURN_BOOK = 7 LIST_MEMBERS = 8 LIST_BOOKS = 9 PRINT_HELP = 10 EXIT = 0 def main(): # print menu print("The commands are:") print(" ", ADD_MEMBER, "to add a member") print(" ", DELETE_MEMBER, "to delete a member") print(" ", ADD_BOOK, "to add a book") print(" ", DELETE_BOOK, "to delete a book") print(" ", FIND_BORROWER, "to find out borrower of a book") print(" ", ISSUE_BOOK, "to issue a book") print(" ", RETURN_BOOK, "to return a book") print(" ", LIST_MEMBERS, "to list members") print(" ", LIST_BOOKS, "to list books") print(" ", PRINT_HELP, "to print this menu") print(" ", EXIT, "to quit") def add_list_entry(members,member,books,book): command=int(input("Enter command:")) if command == ADD_MEMBER: entry=input("Enter member name:") members.append(entry) return entry else: command == ADD_BOOK entry_book=input("Enter book name:") books.append(entry_book) return entry_book def delete_list_entry(members,member,books,book): command=int(input("Enter command:")) if command == DELETE_MEMBER: entry_member=input("Enter member name:") members.remove(entry_member) return entry_member else: command == DELETE_BOOK entry_books=input("Enter book name:") books.remove(entry_books) return entry_books def borrow_book(book_issued): command=int(input("Enter command:")) if command == FIND_BORROWER: book_name = input("Enter book name: ") if book_name not in books: print("No book named", book_name) elif book_name not in borrowed: print(book_name, "is not borrowed") else: print(borrowed[book_name]) return book_name def book_issued(book): command=int(input("Enter command:")) if command == ISSUE_BOOK: book_names

21st Apr 2019, 2:26 AM
Safina Nganga
Safina Nganga - avatar
8 Réponses
+ 2
Have you tried your code in another IDE? SoloLearn's IDE doesn't support multiple inputs during a program. All inputs must be entered at the beginning. That may be the cause of your problem.
21st Apr 2019, 2:46 AM
Diego
Diego - avatar
+ 1
The code you shared had more lines of uncommented text than actual code.
21st Apr 2019, 2:38 AM
Diego
Diego - avatar
+ 1
Let's start from the beginning: Do any error messages appear? If not, how do you know something's wrong?
21st Apr 2019, 2:40 AM
Diego
Diego - avatar
0
thats what i did in the link above all the way above then it just got ignored
21st Apr 2019, 2:35 AM
Safina Nganga
Safina Nganga - avatar
0
i was trying to put the instructions there too my bad
21st Apr 2019, 2:39 AM
Safina Nganga
Safina Nganga - avatar
0
well no when i run that code its not doing what its suppose to do. after it prompts for a command and the user puts in a command it doesnt carry out the right command
21st Apr 2019, 2:42 AM
Safina Nganga
Safina Nganga - avatar
0
ya i was using python
21st Apr 2019, 2:55 AM
Safina Nganga
Safina Nganga - avatar
0
which i did
21st Apr 2019, 2:55 AM
Safina Nganga
Safina Nganga - avatar