0

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

Normal
Lazy
Sisterly
Snooty
Cranky
Jock
Peppy
Smug

The 6 Hobbies are:

Education
Fashion
Fitness
Music
Nature
Playing

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:

Please enter a Villager Name:
>> Betsy
Betsy is Snooty and into Nature

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:

name =str(input("Please enter a Villager Name:"))
print(str(name))

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

Alexander L. Hayes
  • 3,892
  • 4
  • 13
  • 34
Ashton B.
  • 3
  • 2
  • 3
    If all you have is one line of code, perhaps you are giving up too easily? The point of homework like this is to puzzle through them. You haven't yet seriously engaged with the task. – John Coleman Apr 03 '21 at 15:17
  • Take a look at this post https://stackoverflow.com/questions/3996904/generate-random-integers-between-0-and-9/3996930#3996930 – ttyip Apr 03 '21 at 15:22
  • look at random.choice – DevLounge Apr 03 '21 at 23:25

1 Answers1

-3

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

# Import Random Library:
from random import randrange

# Defining Personalities And Hobbies Lists:

personality_list = ["Normal", "Lazy", "Sisterly", "Snooty", "Cranky", "Jock", "Peppy", "Smug"]
hobby_list = ["Education", "Fashion", "Fitness", "Music", "Nature", "Playing"]

# Select Random Item From the lists:

personality = personality_list[randrange(len(personality_list))]
hobby = hobby_list[randrange(len(hobby_list))]

# Take User Input:
name = str(input("Please Enter A Villager Name: "))

# Print The Results: 
print(f"{name} is {personality}, and into {hobby}.")

Output:

Please Enter A Villager Name: Zeid
Zeid is Normal, and into Education.

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/

iamzeid
  • 104
  • 1
  • 2
  • 18
  • 1
    THANK YOU SO MUCH!!! I greatly appreciate it! I was about to lose my mind trying to figure this out! Woo, I really need to get into focus better because I made this a lot harder than it was actually supposed to be... thank you again, sir! :) – Ashton B. Apr 03 '21 at 23:21
  • @AshtonB. Your Welcome! – iamzeid Apr 04 '21 at 21:26