Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8252649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:36:53+00:00 2026-06-08T00:36:53+00:00

Just started learning python (3.2) and have a question. I have created a some

  • 0

Just started learning python (3.2) and have a question. I have created a some code that creates some stats (as in health, magic etc etc) and the numbers are randomly generated. Here is the code…

def stats ():
print ()
print ('Some text.')

done = False
while not done :
charname = input(str('What is the name of the character? '))

hp = random.randint(5,20)
mp = random.randint(4,20)
stre = random.randint(3,20)
agi = random.randint(3,20)
spd = random.randint(3,20)
wis = random.randint(3,20)
intel = random.randint(3,20)
cha = random.randint(3,20)

print (charname)
print ('HP:',hp)
print ('Mana:',mp)
print ('Strength:',stre)
print ('Agility:',agi)
print ('Speed:',spd)
print ('Wisdom:',wis)
print ('Intelligence:',intel)
print ('Charisma:',cha)
print ()


done = input('All done? yes/no ')
if( done == 'yes' ):
    done = True
elif(done == 'no'):
    done = False



while done :
print ()
print ('Now that your stats are done, you can go on your adventure!')
done = False

Now this works fine, but how could I call on this function again in case I wanted to view the stats again with it keeping the same stats it randomly generated before?

Sorry if the question is bit off. Still all new to programming.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T00:36:54+00:00Added an answer on June 8, 2026 at 12:36 am

    Since you’re new to programming, here’s some advice on a different way to store your data (without actually coding it for you).

    First, define a Character class, with attributes for HP, mana, etc. I don’t know if you know about classes yet, but here’s an intro. There are various tricks you can do to get around having to explicitly write in the names for HP, mana, etc, but for learning’s sake, it’s probably better to do them all manually for now.

    Then def a random_character() function that creates a Character object with random attributes, defined like how you’re doing now, but instead of saving them in different variables that Python doesn’t know have anything to do with one another, puts them in a single Character.

    Add a __str__ method to the Character class, so that if char is a Character, print(char) prints out the attributes.

    If you want to be able to keep track of characters, use pickle to store it in files.

    If you have questions about any part of this, just ask. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started using/learning Python and have some questions. I have a text file
I have just started learning python/matplotlib/basemap and could really use some help. How do
I just started learning python and django and I have a question. I got
I have just started learning python version 3 and trying to create a file
Just started learning PySide and is having problem with QTimer I have this #!/usr/bin/python
I have just started learning python and am getting caught up. I come from
I just started learning Python today. I have a list: [text:u'Oranges', text:u'Apples', empty:'', empty:'']
We just started learning about class inheritance and attribute lookup in python. I have
When I started learning Python, I created a few applications just using functions and
I am new to python and just started learning it today. I have installed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.