Question:my out put should look like this:
Welcome to the Galaxy analyzer! How many galaxies would you like to analyze? 3 How many planets are in galaxy 1? 2 What was planet 1’s income last year? 10000 What was planet 2’s income last year? 34000 How many planets are in galaxy 2? 3 What was planet 1’s income last year? 0 What was planet 2’s income last year? 40000 What was planet 3’s income last year? 22000 How many planets are in galaxy 3? 1 What was planet 1’s income last year? 18000
Number of planets: 6 Planets per galaxy: 2.0
Average planetary income: 20666.67 Average galactic income: 41333.33
Income distribution: Less than $20,000: 1 galaxy(s) At least $20,000 but less than $40,000: 0 galaxy(s) At least $40,000 but less than $60,000: 1 galaxy(s) At least $60,000 but less than $80,000: 1 galaxy(s) At least $80,000: 0 galaxy(s)
Would you like to analyze another quadrant (yes/no)? yes
Would you like to analyze another quadrant (yes/no)? no
Thank you for using the Galaxy Analyzer!
Answer:Here’s an idea how to create a list within a list with a user input.
The idea is to first input how many lists your list will contain. Then input every element of every list, one by one, by having a “stop” marker input to know when you want to end adding elements in each sublist. I called mine “done”.
This works only for
intelements. If you input something of a different type or a different string than “done” you will get a
ValueError. You’ll have to update it for your specific needs and requirements. Good luck!
numberOfListswithin your list, then input each element, one per line, like this:
If you have better answer, please add a comment about this, thank you!