May 2017
Intermediate to advanced
280 pages
6h 2m
English
Consider a situation where you want to convert a dictionary into a string; here you can use the str() function. The syntax of the method is as follows:
str(dict)
Consider the following example:
>>> port = {80: "http", 443: "https", 23:"telnet"}>>> port{80: 'http', 443: 'https', 23: 'telnet'}>>> str(port)"{80: 'http', 443: 'https', 23: 'telnet'}">>>
You can easily see the double quotes around the dictionary. Let's get the max key from the dictionary, using the max() function.
Read now
Unlock full access