Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Time to get started on Python homework...
#14
Fiel Wrote:range(1, 50) creates a range from [1, 50)

Here's a more Python noob-friendly way of doing it.

Code:
import random

randomNumbers = []
while len(randomNumbers) < 6:
    randomNumber = random.randint(1, 49)
    if randomNumber not in randomNumbers:
        randomNumbers.append(randomNumber)

for eachRandomNumber in randomNumbers:
    print(str(eachRandomNumber) + " ")

Yeah, that'll probably make my teacher less hard, thus less suspicious. Looks like something I would come up with, thanks Fiel Rolleyes
Reply


Messages In This Thread
Time to get started on Python homework... - by Alley - 2011-10-07, 12:38 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)