In Python: The line endings are missing. Usually a gift line ends with a comma (","), but the last one ends with a period (".") , and the next-to-last ends with "and". Write an if-elifelse to add (+) a comma, a period, or and. code: gifts = ['partridge in a pear tree', 'turtle doves', 'french hens', 'colly birds', 'gold rings', 'geese a-laying', 'swans a-swimming', 'maids a-milking', 'ladies dancing', 'lords a-leaping', 'pipers piping', 'drummers drumming'] ordinals = ['first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelvth'] numerals = ['a', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve'] #numerals=numerals[0].title() first_verse = 'On the X day of Christmas my true love sent to me' # Your work begins here. # RULES: # 1. Your program must use the variables declared above # 2. Your program may only use these string literals: # "." "," "and" "" # All other strings must be obtained from the variables above. day = 0 while day < 4: # Your code goes in this loop. #print (day+1,numerals[day],ordinals[day]) #print(first_verse.replace('X', ordinals[day])) print(first_verse.replace('X', ordinals[day])) day=day+1 gift_index = day end_index = 0 while gift_index > end_index: print(numerals[gift_index-1],gifts[gift_index-1]) gift_index -= 1
In Python:
The line endings are missing. Usually a gift line ends with a comma (","), but the last one ends with a period (".") , and the next-to-last ends with "and". Write an if-elifelse to add (+) a comma, a period, or and.
code:
gifts = ['partridge in a pear tree',
'turtle doves',
'french hens',
'colly birds',
'gold rings',
'geese a-laying',
'swans a-swimming',
'maids a-milking',
'ladies dancing',
'lords a-leaping',
'pipers piping',
'drummers drumming']
ordinals = ['first', 'second', 'third', 'fourth',
'fifth', 'sixth', 'seventh', 'eighth',
'ninth', 'tenth', 'eleventh', 'twelvth']
numerals = ['a', 'two', 'three', 'four', 'five', 'six', 'seven',
'eight', 'nine', 'ten', 'eleven', 'twelve']
#numerals=numerals[0].title()
first_verse = 'On the X day of Christmas my true love sent to me'
# Your work begins here.
# RULES:
# 1. Your
# 2. Your program may only use these string literals:
# "." "," "and" ""
# All other strings must be obtained from the variables above.
day = 0
while day < 4:
# Your code goes in this loop.
#print (day+1,numerals[day],ordinals[day])
#print(first_verse.replace('X', ordinals[day]))
print(first_verse.replace('X', ordinals[day]))
day=day+1
gift_index = day
end_index = 0
while gift_index > end_index:
print(numerals[gift_index-1],gifts[gift_index-1])
gift_index -= 1
pass
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images