from typing import Optional


def from_wrong_answer(text: str, grade: Optional[int] = None) -> str:
	"""
	Generates GIFT-ready text from a (single) wrong answer and, optionally, its grade.

	Parameters
	----------
	text : str
		The phrasing of the answer.
	grade : int, optional
		The worth or grade.

	Returns
	-------
	out: str
		GIFT-ready text.

	"""

	if grade:

		return f'~%{grade}%{text}'

	else:

		return f'~{text}'