Inquiry answerer
Python 3, 62 bytes
lambda s:['Yes',*s[:-1].split(','),'No'][~(','in s)*('?'in s)]
Try it online!
The expression ~(','in s)*('?'in s)
evaluates to 0
(i.e. 'Yes'
) if the string does not contain a '?'
, else -1
(i.e. 'No'
) if the string does not contain a ','
, and otherwise -2
(i.e. the last comma-separated section of the string excluding the last character).
05AB1E, 20 19 bytes
'?åi',¡”€–”0ǝθ¨ë”…Ü
-1 byte thanks to @Grimy.
Try it online or verify all test cases.
Explanation:
'?åi '# If the (implicit) input contains a "?":
',¡ '# Split the (implicit) input on ","
”€–” # Push dictionary string "Not"
0ǝ # Insert it at the first position (index 0) in the list
θ # Then get the last item of the list
¨ # And remove the last character
# (either the "?" of the original input; or the "t" in "Not")
ë # Else:
”…Ü # Push dictionary string "Yes"
# (after which the top of the stack is output implicitly as result)
See this 05AB1E tip of mine (section How to use the dictionary?) to understand why ”€–”
is "Not"
and ”…Ü
is "Yes"
.
JavaScript (ES6), 53 52 bytes
s=>(m=s.match(/(,?)([^,]*)\?/))?m[1]?m[2]:'No':'Yes'
Try it online!
Commented
s => // s = input string
( m = s.match( // m is the result of matching in s:
// +------------> an optional comma
// | +------> followed by a string containing no comma
// | | +--> followed by a question mark
// <--><-----><>
/(,?)([^,]*)\?/
)) ? // if m is not null:
m[1] ? // if the comma exists:
m[2] // output the string following it
: // else:
'No' // output 'No'
: // else:
'Yes' // output 'Yes'