diff options
Diffstat (limited to 'python3.html.markdown')
| -rw-r--r-- | python3.html.markdown | 13 | 
1 files changed, 12 insertions, 1 deletions
| diff --git a/python3.html.markdown b/python3.html.markdown index c4f15867..ef78ce37 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -155,7 +155,7 @@ len("This is a string")  # => 16  name = "Reiko"  f"She said her name is {name}." # => "She said her name is Reiko"  # You can basically put any Python statement inside the braces and it will be output in the string. -f"{name} is {len(name)} characters long." +f"{name} is {len(name)} characters long." # => "Reiko is 5 characters long."  # None is an object @@ -462,8 +462,19 @@ prints:  """  for i in range(4, 8, 2):      print(i) + +""" +To loop over a list, and retrieve both the index and the value of each item in the list +prints: +    0 dog +    1 cat +    2 mouse  """ +list = ["dog", "cat", "mouse"] +for i, value in enumerate(list): +    print(i, value) +"""  While loops go until a condition is no longer met.  prints:      0 | 
