Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files must be closed #1

Open
TEger77 opened this issue Sep 18, 2021 · 2 comments
Open

Files must be closed #1

TEger77 opened this issue Sep 18, 2021 · 2 comments

Comments

@TEger77
Copy link

TEger77 commented Sep 18, 2021

bookDatabase.close() must be used after open..

@hydr0phobia
Copy link

The code provided here doesnt seem to be able to lend books that are originally in the text database, only the ones that the user have added later. Any suggestions?

@UtkarshRaj130
Copy link

The code provided here doesnt seem to be able to lend books that are originally in the text database, only the ones that the user have added later. Any suggestions?

Because while reading and adding books to the list it is taking '\n' also at last of the book name, while for those books which are added later don't have the extra '\n' character at last.
The bookList formed by reading the text file is like: ['Python Crash Course\n', 'Head First Python\n', 'Learn Python3 - The Hard Way\n', 'Think Python\n', 'Automate The Boring Stuff using Python']
The solution is to use .strip() , while adding the books to the list to remove any white spaces(including '\n') from the book name so the corrected code for adding books into the list from the database is :
for book in bookDatabase:
booksList.append(book.strip())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants