How to write a sentence containing a question within it?

This is mainly a matter of style, but it's common to use either dashes or parentheses if you wish to include a question—or more than one sentence—parenthetically.

Dashes and parentheses are used rather than commas because they more visually separate the parenthetical information from the main text, making it easier to read the entire sentence.

Also generally speaking, the first letter that's part of the aside is in lowercase, and, if there are multiple sentence, the final period is not included—although question marks and exclamation points would be.

A long article that discusses the use of information inside parentheses, and how to punctuate within that, is "Using Parentheses '()' in Sentences: (8 Rules You Must Know)" at Punctuation Check. Although it applies to parentheses specifically, the same guidance could be applied to dashes.


Saying that, a common way of writing the sentence in the question would be this:

And—who knows?—it might actually work.


The following is an example sentence used by The Chicago Manual of Style (6.98):

Come on in (quietly, please!) and take a seat.


Of course, some people would say that this kind of thing should not be done in the first place. For instance, it's unlikely that anybody would think kindly of a parenthetical question being asked in formal writing.

Rather than doing that, the sentence would likely be rewritten to move the parenthetical question to a second sentence:

And it might actually work. But who knows?