mercredi 9 septembre 2015

Sum random numbers

So I'm seriously struggling with this python assignment I've got. My assignment is to write a program that uses main and a void function named randnums that generates 6 random numbers between 0 and 10, Then prints them all on one line. Also, randnums needs to print the total of the 6 number on a new line.

Here's the code I've created so far:

import random

def main():
    for count in range(6):
        randnums = random.randrange(1,10)
        print(randnums, end='')

main()

I can't figure out how to sum the 6 numbers up.




Aucun commentaire:

Enregistrer un commentaire