226k views
3 votes
Select the function completion that satisfies this docstring description: def convert_to_string(nums): """ (list of number) -> NoneType Replace each item in nums with its string equivalent. >>> nums

User Eshwar
by
4.5k points

1 Answer

5 votes

Answer:

def convert_to_string(nums):

for i in range(len(nums)):

nums[i] = str(nums[i])

nums = [7, 28, 92]

print(nums)

convert_to_string(nums)

print(nums)

Step-by-step explanation:

Create a function called convert_to_string that takes one parameter, nums

Create a for loop that iterates through the nums. Inside the loop, set each item to its string equivalent using type casting (str)

Initialize a list

Print the list before the function call

Call the function, passing the list as a parameter

Then, print the list again to see the difference

User Brigand
by
5.3k points