This block of code is used to display a random string from a list. The lists I've made are categories based on when the dialogue is appropriate to use. For example, there is a list for greetings, one for goodbyes, and as displayed below: one for when the input isn't understood. In these lists, some of the strings use the character's name (which is a variable) and some of them don't. In order to give the player's name to a string that uses it, use of string formatting is necessary, but when the randomly chosen string doesn't use string formatting I get this error: TypeError: not all arguments converted during string formatting
How could I avoid this error? Use of exception handling comes to mind, but as far as I know wouldn't work due to having to fit the print statment,
In the "functions" Module :
print(random.choice(strings.notUnderstand) % username)
In the "strings" Module :
notUnderstand = [
"""Pardon?
""",
"""I\'m sorry %s, can you repeat that?
""",
"""I don\'t understand what you mean by that.
"""
]