List comprehensions accept conditional statements, to evaluate the provided expression only if certain conditions are met:
spam = [i * 2 for i in iterable if i > 0]
As you can see from the output, the list of characters generated from pascal_or_camel_cased_string has been joined. Since the expression inside the list comprehension is evaluated for each character, the result is a lowercase string with all the characters separated by an underscore.
Follow the example above to add an if clause to your list comprehension so that the expression is executed only if the character is uppercase.