Program 4: Write a random number generator that generates random numbers between 1 and 6 (simulates a dice)

Clear Doubts with Computer Tutor
In case you’re facing problems in understanding concepts, writing programs, solving questions, want to learn fun facts | tips | tricks or absolutely anything around computer science, feel free to join CTs learner-teacher community: students.computertutor.in

import random
def rolladice():
   counter = 0
   myList = []
   while (counter) < 6:
       randomNumber = random.randint(1,6)
       myList.append(randomNumber)
       counter = counter + 1
       if (counter)>=6:
           pass
       else:
           return myList

# Take user input here
n=1
while(n==1):
   n = int(input("Enter 1 to roll a dice and get a random number:"))
   print(rolladice())

You cannot copy content of this page