Forráskód Böngészése

Added a second example on print formatting.

Gogs 7 éve
szülő
commit
cc43b6c397
1 módosított fájl, 1 hozzáadás és 1 törlés
  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))