Python Forum
How can I assign "multiple variables" to a single "value"?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I assign "multiple variables" to a single "value"?
#1
I'm sorry if the title confused you. This is the first time I'm posting here, forgive me if I have mistakes.

Here's what I'm trying to do:
I'm trying to assign multiple variables to a single value;

from globals import health
from globals import stamina
from globals import magicka

assassin = "Assassin"; health += 100; stamina += 140; magicka += 60
mage = "Mage"; health += 80; stamina += 60; magicka += 160
warrior = "Warrior"; health += 140; stamina += 120; magicka += 40
Health, stamina and magicka variables are in a file called globals.py, you can see it clearly. And my globals.py file is as following;

gold = 0
health = 0
stamina = 0
mana = 0
mage = "Mage" is my value here. This will not be changed. However, since health, stamina, and mana are variables, and the player will drain those attributes, these will change throughout the game. So I'm trying to assign different stat pools to different roles.
I don't get an error. When I print the role, health, stamina and magicka, the output is this;

Output:
Mage 320 320 260
These are the output values I keep getting. Doesn't matter what role I choose. The only thing changing is the role. I keep getting the same/similar health, stamina and magicka values. I don't know how can I assign multiple variables to a single value. I'm still learning Python and I'm coding a simple text RPG while learning to keep my interest at its peak levels. Sorry, it's currently 3 A.M here and I'm getting tired. I tried to roughly translate my original codes to English. So I simply rewrote the whole code. If you see any mistakes, there are none in my original files.

All help is greatly appreciated. Thanks so much in advance!
Reply


Messages In This Thread
How can I assign "multiple variables" to a single "value"? - by Psycpus - Oct-04-2021, 12:18 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Create X Number of Variables and Assign Data RockBlok 8 1,048 Nov-14-2023, 08:46 AM
Last Post: perfringo
  Create multiple/single csv file for each sql records mg24 6 1,478 Sep-29-2022, 08:06 AM
Last Post: buran
  Reshaping a single column in to multiple column using Python sahar 7 2,129 Jun-20-2022, 12:35 PM
Last Post: deanhystad
  Storing variables into one file for use in multiple Jupyter notebooks devansing 1 1,793 Feb-05-2022, 10:04 AM
Last Post: ibreeden
  Split single column to multiple columns SriRajesh 1 1,359 Jan-07-2022, 06:43 PM
Last Post: jefsummers
  Delete multiple comments with a single API call (facebook) Ascalon 0 2,355 Dec-04-2021, 08:33 PM
Last Post: Ascalon
  Ploting single column with multiple category drunkenneo 1 2,010 May-26-2021, 04:51 PM
Last Post: jefsummers
  Inserting multiple rows in a single request. swaroop 2 2,974 Jan-11-2021, 01:34 PM
Last Post: swaroop
  Fetching data from multiple tables in a single request. swaroop 0 1,927 Jan-09-2021, 04:23 PM
Last Post: swaroop
  How to append multiple <class 'str'> into a single List ahmedwaqas92 2 2,372 Jan-07-2021, 08:17 AM
Last Post: ahmedwaqas92

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020