Ask Question
22 March, 00:04

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

+1
Answers (1)
  1. 22 March, 00:11
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers