Question: use python 6. Ask the user for a number, then a word, and then print out a phrase that depends on the number and the

6. Ask the user for a number, then a word, and then print out a phrase that depends on the number and the word. You should pluralize the word by adding an "s" to the end whenever they enter a number that is O or greater than 1. In: 0 In: bat Out: O bats In: 1 In: cat Out: 1 cat In: 4 In: dog Out: 4 dogs Let's implement some more advanced rules: Words ends in: -ife -sh/ch Becomes: -ives -shes/ches Example: life -> lives bush -> bushes church -> churches cactus -> cacti guy -> guys -ay/oyley/uy -ays/oysleys/uys toy -> toys key -> keys way -> ways fly -> flies hat -> hats -ies everything else add -s To do this, you'll have to use string slicing. The following table provides the shortcuts for common tools you might need: word = "computerz" print(word[:5]) # prints "compu" print(word[:-1]) # prints "computer" print(word(4:1) #prints "uterz" print(word (-3:]) # prints "erz
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
