Home > Mobile >  How to take one number in variable and split it into two numbers that go into seperate variables?
How to take one number in variable and split it into two numbers that go into seperate variables?

Time:03-14

I have this code:

import random

people = random.randrange(1, 11)

fate = random.randint(1, 11)

males = 0

females = 0

I would like to take the random number of people, and split that up randomly into two groups of numbers, one group will be male and the other female. So, say I have the number 9 in the people variable, I would then like to split it into two random numbers that equal 9, and then assign them to the variables males and females.

How would I go about doing this?

CodePudding user response:

males = random.randint(0, people)
females = 9 - males

if you meant sum of males and females should be equal people

  • Related