jeudi 3 novembre 2022

How to shorten a repetitive part of basic python code? [duplicate]

I am new to coding, and just started learning Python last week. I made this Powerball number generator to practice:

import random

print(random.randrange(1, 70))

import random

print(random.randrange(1,70))

import random

print(random.randrange(1, 70))

import random

print(random.randrange(1,70))

import random

print(random.randrange(1, 70))

import random

print(random.randrange(1,27))

I am wondering, how can I shorten this, since the first 5 "import random prints" are exactly identical?

Thanks ahead for helping a noob!




Aucun commentaire:

Enregistrer un commentaire