Hello, I am currently stuck on a homework lab for zybooks and I am clueless as to what I am supposed to add to my code to make it work.
Prompt:
The top 3 most popular male names of 2017 are Oliver, Declan, and Henry according to babynames.com.
Write a program that modifies the male_names set by removing a name and adding a different name.
Sample output with inputs: 'Oliver' 'Atlas'
{ 'Atlas', 'Declan', 'Henry' }
NOTE: Because sets are unordered, the order in which the names in male_names appear may differ from above.
My code so far:
Prompt:
The top 3 most popular male names of 2017 are Oliver, Declan, and Henry according to babynames.com.
Write a program that modifies the male_names set by removing a name and adding a different name.
Sample output with inputs: 'Oliver' 'Atlas'
{ 'Atlas', 'Declan', 'Henry' }
NOTE: Because sets are unordered, the order in which the names in male_names appear may differ from above.
My code so far:
male_names = { 'Oliver', 'Declan', 'Henry' } name_to_remove = input() name_to_add = input() ''' Your solution goes here ''' male_names.remove('Oliver') male_names.add('Atlas') print(male_names)I tried to remove the first name, and add a new one so far but I notice the expected output prints the names in a different order, some hints in the right direction would help.
Output:Testing with inputs:
'Oliver' 'Atlas'
Your output
{ 'Atlas', 'Declan', 'Henry' }
Testing with inputs: 'Declan' 'Noah'
Output differs. See highlights below.
Your output
{ 'Atlas', 'Declan', 'Henry' }
Expected output
{ 'Henry', 'Noah', 'Oliver' }
buran write Feb-17-2021, 09:35 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.