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.
sum. - Chris Martinn = 0outside/before the loop,n +=randnumsin the loop. print n outside/after the loop - Padraic Cunninghamrandnumsfunction. You can get the right output and it will still be marked wrong for not following the instruction. - Paul