コード例 #1
0
     try:
         num_sides = int(num_sides)
     except ValueError:
         print('Sorry, that wasn\'t a number!')
         continue
     if num_sides >= 3:
         num_rolls = input('How many times do you want to roll the die? ')
         try:
             num_rolls = int(num_rolls)
         except ValueError:
             print('Sorry, that wasn\'t a number!')
             continue
         if num_rolls >= 1:
             die1 = Die(num_sides)
             die1.roll(num_rolls)
             die1.roll_stats()
             print(die1.list_of_rolls)
             for i, freq in zip(range(len(die1.freq_list)), die1.freq_list):
                 print(f'{i+1}:{freq}', end='\t')
         else:
             print('Sorry, you have to roll the die at least once!')
     else:
         print('Sorry, the die must have at least 3 sides!')
 elif choice == str(2):
     num_flips = input('How many times do you want to flip the coin? ')
     try:
         num_flips = int(num_flips)
     except ValueError:
         print('Sorry, that wasn\'t a number!')
         continue
     if num_flips >= 1: