Formatted String

Formatted String

Tags: String Manipulation Basics

Credit: CodingChallenge

Difficulty: Beginner

Type: Text

Category: Practice

Time Allowed: 5 s

Description:

Write a function that takes a context string and a value, and returns a formatted string combining both. This problem is designed to help you practice string formatting. The function should accept two parameters and return the formatted string.

Constraints:

  • The first input will be a string (context).
  • The second input can be any primitive data type (int, float, str, bool).
  • The function should return a string that combines the context and the value.

Example:

  • Input: "My name is John, I am ", 36
  • Output: "My name is John, I am 36"

Test Case Input Expected Output
1 ["My name is John, I am ", 36] "My name is John, I am 36"
2 ["The result is ", 42] "The result is 42"
3 ["Pi is approximately ", 3.14] "Pi is approximately 3.14"
4 ["The answer is ", True] "The answer is True"
5 ["Number: ", 1234567890] "Number: 1234567890"
6 ["Boolean value: ", False] "Boolean value: False"
7 ["Hello, ", "World!"] "Hello, World!"

Please register or login to submit solutions to challenges.