Question: Write a function called madLib that takes in a string and a dictionary. The input dictionary will have keys that are integers and data values
Write a function called madLib that takes in a string and a dictionary. The input dictionary will have keys that are integers and data values that are strings Your function should replace the word in the original string at each key value with the data for that key value. Your function should return an updated string. 3. Ex: inputString - "Ilike chocolate milk inputDictionary # {0:"we", 3:"cookies") Should return the string "we like chocolate cookies You may find the split() and str) functions for strings and lists to be useful NSY 3010-Fall 2018 Homework #4 Due: 8am, Sept 18 Write a function called multiplyNumbersByAConstant that takes in a list of numbers and a single scalar (these can all be integers or floating point numbers) Using a single list comprehension, make a new list that has the input scalar (number) added to each term in the original list. Your code should return the modified list 4. Ex: For inputist 1,2,3] and scalar 3, the list you would return is [3,6,9
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
