Explorar el Código

Added a second example on print formatting.

Gogs hace 7 años
padre
commit
cc43b6c397
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  1. 1 1
      examples/simplefunction.py

+ 1 - 1
examples/simplefunction.py

@@ -2,7 +2,7 @@ def example(firstargument, secondargument, thirdargument="N/A"):
     """ Prints a string based on the two arguments. """
     # This is python3.6 syntax:
 #    print(f"{firstargument} is the first argument.")
-    print("{} is the first argument.".format(firstargument))
+    print("{a} is the first argument.".format(a = firstargument)) # Name the argument if you want
     print("{} is the second argument.".format(secondargument))
     print("{} is the third argument.".format(thirdargument))