How can I modify + add from my code so that it prints both the name of the winner and the winning number?! So let's say William with random number 7 matched with winning number 7. Then I want it to print that "William is the winner and the winning number was 7!". In the other hand, if the winning number was 5 and no one had that matching number, I want it to print out "There is no winner". Thanks in advance!
import random
from random import sample
character_count = 5
names = ['John', 'William', 'James', 'George', 'Charles', 'Frank', 'Joseph', 'Henry', 'Robert', 'Thomas', 'Edward',
'Harry', 'Walter', 'Arthur', 'Fred', 'Albert', 'Samuel', 'Clarence', 'Louis', 'David', 'Mary', 'Anna', 'Emma', 'Elizabeth',
'Margaret', 'Minnie', 'Ida', 'Bertha', 'Clara', 'Alice', 'Annie', 'Florence', 'Bessie', 'Grace', 'Ethel', 'Sarah',
'Ella', 'Martha', 'Nellie', 'Mabel']
generate_random_names = (sample(names, k=character_count))
random_number = random.sample(range(1,10), (5))
winning_number = random.sample(range(1,10), (1))
character_status = list(zip(generate_random_names, random_number))
char_one_info = (character_status[0])
char_two_info = (character_status[1])
char_three_info = (character_status[2])
char_four_info = (character_status[3])
char_five_info = (character_status[4])
while True:
winning_number == char_one_info[1] or winning_number == char_two_info[1] or winning_number == char_three_info[1] or winning_number == char_four_info[1] or winning_number == char_five_info[1]
print (True)
Aucun commentaire:
Enregistrer un commentaire