0

I want to make a random police unit generator and the code is like so:

import random
unitnumbers = ('unit' , random.randint(1,999))
print(unitnumbers)

However, rather than printing "unit 63" , it prints ('unit', 378)

How could I make it print only the unit and random number?

0

2 Answers 2

3

You are making the value of unitnumbers a tuple. You should instead make it a string like that:

unitnumbers = "unit " + str(random.randint(1,999))
Sign up to request clarification or add additional context in comments.

Comments

0

This should do that:

import random
unitnumbers = 'unit %d' % random.randint(1,999)
print(unitnumbers)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.