Note that there are some explanatory texts on larger screens.

plurals
  1. POBeginner-level virtual library program troubles, how do I let the user create an array or 'def'?
    primarykey
    data
    text
    <p>Alright, so I'm bad with words so I painted you all a beautiful picture hoping that whole picture is worth a thousand words thing is true:</p> <p><img src="https://i.stack.imgur.com/stmhM.png" alt="enter image description here"></p> <p>However, if the picture didn't do the job I'll try to describe my issue. I'm trying to make a sort of beginner level virtual library in Python. However, first here is my code thus-far:</p> <pre><code>book_title = [] book_page_count = [] book_publish_date = [] book_author = [] def elsePhrase(): print("Wrong input, I'll just send you back to the menu.\n") menu() def menu(): print("- - - - - - - -- PROGRAM MENU -- - - - - - - -") print("Welcome Book Sorter, what would you like to do? \n") print("1 ) Add a book") print("2 ) List a specific book's details") print("3 ) List all recorded complete book details") menu_Choice = input("4 ) Exit.\n\n") if menu_Choice == 1: add_book() elif menu_Choice == 2: list_book() elif menu_Choice == 3: list_all() elif menu_Choice == 4: exit() else: print("Error: Please enter a number as shown and try again.") print("-----------------------------------------------------------\n\n") menu() def add_book(): print("\nYou selected: Add book. Please fill out the following information: \n") title = raw_input("Book title: ") book_title.append(str(title)) page_count = raw_input("Book page count: ") book_page_count.append(page_count) publish_date = raw_input("Book publish date: ") book_publish_date.append(publish_date) author = raw_input("Book author: ") book_author.append(author) print("\nProcess complete.") Restart() def list_book(): # Find out how to fix this print("You selected: list book. Please select a book from below: ") print(book_title) choice = raw_input("\n") def list_all(): #Find out how to make this actually look not-shitty and make sense. print(book_title) print(book_page_count) print(book_publish_date) print(book_author) def Restart(): toMenu = raw_input("\n\tWould you like to go back to the main menu? Y / N\t\n\n") if toMenu == "Y": menu() elif toMenu == "N": toExit = raw_input("Oh.. Okay then want me to just exit the program? Y /N\n\n") if toExit == "Y": exit() elif toExit == "N": print("Alright, I guess I'll just leave you be, you know where the big red X button is I guess. Take your time.") else: elsePhrase() else: elsePhrase() def main(): menu() main() </code></pre> <p>Yeah, it's bad I know, I'm sorry; I am still trying to learn.</p> <p>Anyway, where I am having trouble is I want to basically create a unique array or 'def' that has all this information in it.. So say for example I want to add a book into this library it will make a block of information that holds the title, author, page count, publish date, etc.. All together in a comfortable little box of information I can call later. The issue is I have no idea how to actually do this with an undetermined amount of information defined by the user.</p> <p>So.. That about sums it up I guess, thanks very much in advance for any help!</p> <p><strong>TL;DR: I don't understand how to let the user enter a block of seperate information (Title, author, page count, etc..), bind it all together, and then print it out again on demand easily(Saying "Find details on X and Y" where X is book 1 / all the information entered in step 1 and Y is all the information on book 2 in a different step 1. All done multiple-infinite times.</strong></p> <p>I hope this made sense, please free to ask me anything, I just would really like to be able to do this, thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload