Ask Question
24 March, 06:17

Create a function, str_replace, that takes 2 arguments: int list and index in list is a list of single digit integers index is the index that will be checked - such as with int_list[index] Function replicates purpose of task "replace items in a list" above and replaces an integer with a string "small" or "large" return int_list

+4
Answers (1)
  1. 24 March, 08:31
    0
    def str_replace (int_list, index):

    if int_list[index] < 7:

    int_list[index] = "small"

    elif int_list[index] > 7:

    int_list[index] = "large"

    return int_list

    Explanation:

    I believe you forgot to mention the comparison value. I checked if the integer at the given index is smaller/greater than 7. If that is not your number to check, you may just change the value.

    Create a function called def str_replace that takes two parameters, an integer list and an index

    Check if the number in given index is smaller than 7. If it is replace the number with "small".

    Check if the number in given index is greater than 7. If it is replace the number with "large".

    Return the list
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Create a function, str_replace, that takes 2 arguments: int list and index in list is a list of single digit integers index is the index ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers