42.1k views
2 votes
Return a formatted string with numbers The function below takes three numerical inputs: num1, num2, and num3. Implement it to return a formatted string with an underscore between the first two numbers and space, exclamation point, and another space between the second and third number. For example, if the inputs are 1, 2, and 3, then the function should return the string '1_2 ! 3'.

User Andybega
by
5.4k points

1 Answer

4 votes

Answer:

In Python:

def ret_formatted(num1,num2,num3):

result = str(num1)+"_"+str(num2)+" ! "+str(num3)

return result

Step-by-step explanation:

This defines the function

def ret_formatted(num1,num2,num3):

This generates the output string

result = str(num1)+"_"+str(num2)+" ! "+str(num3)

This returns the result string

return result

User RandyDaddis
by
5.8k points