Skip to content
Advertisement

How do you store hobbies and personalities in a list and then generate them with a different random number to determine which hob or person you get? [closed]

In the video game Animal Crossing: New Horizons, villagers are organized by Personality and Hobby. The 8 Personalities are:

JavaScript

The 6 Hobbies are:

JavaScript

Create a program that allows the user to create their own Animal Crossing villager. The user should be able to enter a name, after which the program will choose a random Hobby and Personality for the villager:

JavaScript

The program should store both the Hobbies and Personalities in lists, and when creating a villager it should randomly choose from each list for the personality.

Requirements: · Both Personalities and Hobbies must be stored in lists · You must generate a different random number to determine the hobby and personality (that is, don’t generate 1 random number and use it for both lists, as that prevents many combinations) · In randomizing, you should make sure that all combinations are possible (that is, make sure you don’t accidentally leave out a personality or hobby from random generation) · The program shouldn’t crash

So far, I’ve gotten the name part down which is:

JavaScript

But I can’t figure out how to randomize the personalities and hobbies with a different number.

Advertisement

Answer

Here is My Code With Some Comments To Explain What I Did.

JavaScript

Output:

JavaScript

Note: In The Last Line I Used Something Called F String, Which only works With Python 3.6 or later. For more info about it and it’s alternatives, you can visit this page: https://realpython.com/python-f-strings/

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement