diff --git a/strings.html b/strings.html index f909fe5..edc98c7 100755 --- a/strings.html +++ b/strings.html @@ -261,7 +261,7 @@ experience of years. {'password': 'PapayaWhip', 'user': 'pilgrim', 'database': 'master'}
    -
  1. The split() string method takes one argument, a delimiter, and split a string into a list of strings based on the delimiter. Here, the delimiter is an ampersand character, but it could be anything. +
  2. The split() string method takes one argument, a delimiter, and splits a string into a list of strings based on the delimiter. Here, the delimiter is an ampersand character, but it could be anything.
  3. Now we have a list of strings, each with a key, followed by an equals sign, followed by a value. We can use a list comprehension to iterate over the entire list and split each string into two strings based on the first equals sign. (In theory, a value could contain an equals sign too. If we just used 'key=value=foo'.split('='), we would end up with a three-item list ['key', 'value', 'foo'].)
  4. Finally, Python can turn that list-of-lists into a dictionary simply by passing it to the dict() function.