Data Type Identifier - Problem
Given a value, determine whether it is an integer, float, string, or boolean.
Your task is to analyze the input value and return the appropriate data type as a string. The function should be able to distinguish between:
"integer"- whole numbers like 42, -15, 0"float"- decimal numbers like 3.14, -2.5, 0.0"string"- text values like "hello", "123abc", """boolean"- true or false values
Return the detected type as a lowercase string.
Input & Output
Example 1 — Integer Value
$
Input:
value = "42"
›
Output:
"integer"
💡 Note:
The string "42" represents a whole number without decimal places, so it's classified as an integer.
Example 2 — Float Value
$
Input:
value = "3.14"
›
Output:
"float"
💡 Note:
The string "3.14" contains a decimal point and represents a floating-point number.
Example 3 — Boolean Value
$
Input:
value = "true"
›
Output:
"boolean"
💡 Note:
The string "true" is a boolean value (case-insensitive match).
Constraints
- Input will be a string representation of a value
- Boolean values are case-insensitive ("True", "FALSE", etc.)
- Integer values can be positive or negative
- Float values must contain a decimal point
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code