[Tutor] My response. Not expecting a reply.
Ed Connell
edwinconnell at gmail.com
Tue May 2 11:18:58 EDT 2023
Thank you for your response and particularly for your suggestions.
This is my attempt to implement them.
My real question was the malfunctions. I have concluded that my system
shows the results while it is still bringing up the standard output window.
I should have said, "attempts to write before..."
Oh well!
Ed
import random
import time
for run in range(1): #usually 1 but trying multiple runs through in one
pass.
# build result, number choices, and choice count lists
result = []
nums = list(range(10))
choice_count = 10*[0]
print(f'\n\nrun {run+1}, number choices {nums}\n')
time.sleep(0.5) # seems to work for 0.5 or more uncommented
for _ in range( 36 ): # tried 10 - 40
choice = random.choice( nums )
result.append(choice)
print(result)
choice_count[choice] += 1
if choice_count[choice] == 4:
nums.remove(choice)
print( 'Removing', choice,'leaving', sorted(nums) )
numavailable = []
for i in range(10):
numavailable.append(4-choice_count[i])
print()
print('numbers left',sorted(nums))
print('result',result)
print('number of each used',choice_count)
print('number left of each',numavailable)
--
I have a right and a left brain, but there is nothing right in the left one
and there is nothing left in the right one!
More information about the Tutor
mailing list