<Ctrl><Shift>R once I highlighted ONLY the commands that I wanted to turn into a function.
My original code block that I wanted to refactor began with a comment and the last line had a comment at the end.
# this code does this
print(a)
print(b) #another comment here.
Refactoring only worked when I ONLY highlighted the print commands.
# this code does this
print(a)
print(b) #another comment here.