Here is an image of correct code (in fact, code of a previous question):
If I copy this code and paste it in a code sample in this editor, I got this (another image):
So I'm obliged to add a tab at the beginning of the whole code (this is not valid Python code any more as can be seen by the red line under def):
Then, if I paste into a code sample, I obtain the following which is not yet correct as the first line is indented twice (and we don’t have any syntax colors):
# original code with right indentation
def animals(ani1, ani2, ani3):
if ani1 == ani2 or ani1 == ani3:
return "Match was Found"
elif ani2 == ani1 or ani2 == ani3:
return "Match was Found"
elif ani3 == ani2 or ani3 == ani1:
return "Match was Found"
else:
return "No Match Found"
print(animals("dogs", "dogs", "cats"))
So I'm obliged to correct by hand to have a final result as expected:
# original code with right indentation
def animals(ani1, ani2, ani3):
if ani1 == ani2 or ani1 == ani3:
return "Match was Found"
elif ani2 == ani1 or ani2 == ani3:
return "Match was Found"
elif ani3 == ani2 or ani3 == ani1:
return "Match was Found"
else:
return "No Match Found"
print(animals("dogs", "dogs", "cats"))
Then I go back to my editor (Visual Studio Code) to restore the correct indentation.
What is the best way to paste Python code directly without all this stuff?
{}
or Ctrl-K ?