In this article we will see how to create a list of lists which contain string data types. The inner list themselves or of string data type and they may contain numeric or strings as their elements.Using strip and splitWe use these two methods which will first separate out the lists and then convert each element of the list to a string.Example Live Demolist1 = [ '[0, 1, 2, 3]', '["Mon", "Tue", "Wed", "Thu"]' ] print ("The given list is : " + str(list1)) print("") # using strip() + split() result = [k.strip("[]").split(", ") for k in list1] print ("Converting list ... Read More
The cmp() is part of the python standard library which compares two integers. The result of comparison is -1 if the first integer is smaller than second and 1 if the first integer is greater than the second. If both are equal the result of cmp() is zero.Below example illustrates different scenario showing the use of cmp() method.Example Live Demodef cmp(x, y): return (x > y) - (x < y) #x>y x = 5 y = 3 print("The cmp value for x>y is : ",cmp(x, y),"") #xy is : 1 The cmp value for x
Use the tag to define area in an image map in HTML.The HTML tag supports the following additional attributes −AttributeValueDescriptionAltTextSpecifies an alternate text for the area.coordsif shape = "rect" then coords = "left, top, right, bottom"if shape = "circ" then coords = "centerx, centery, radius"if shape = "poly" then coords = "x1, y1, x2, y2, .., xn, yn"Specifies the coordinates appropriate to the shape attribute to define a region of an image for image maps.download filenameSpecifies that the target gets downloaded when the hyperlink is clicked by the user.HrefURLSpecifies the URL of a page or the name of ... Read More
In this article we consider a dictionary where the values are presented as lists. Then we consider clearing those values from the lists. We have two approaches here. One is to use the clear methods and another is to designate empty values to each key using list comprehension.Example Live Demox1 = {"Apple" : [4, 6, 9, 2], "Grape" : [7, 8, 2, 1], "Orange" : [3, 6, 2, 4]} x2 = {"mango" : [4, 6, 9, 2], "pineapple" : [7, 8, 2, 1], "cherry" : [3, 6, 2, 4]} print("The given input is : " + str(x1)) # using loop + ... Read More
Use the tag to blink a text. The HTML tag is used to enclose a text to make it blink.You can try to run the following code to implement tag − Note − Do not use this element as it is obsolete.Example HTML blink Tag This text will blink in Netscape Version 5.0
Use the tag to display text ruby annotation. The HTML5 tag is used for pronunciation of character in ruby annotations. These are for showing pronunciation of East Asian characters.ExampleYou can try to run the following code to display text ruby annotation − HTML Rt Tag 漢 (Kan) 字 (ji)
The HTML tag specifies to show browsers that do not support the ruby annotations. Ruby Annotations are used in East Asian typography.ExampleYou can try to run the following code to implement tag in HTML − HTML Rp Tag 漢 (Kan) 字 (ji)
Use the tag to create a progress bar in HTML. The HTML tag specifies a completion progress of a task. It is displayed as a progress bar. The value of progress bar can be manipulated by JavaScript.The following are the attributes −AttributeValueDescriptionmax maxIt should have a value greater than zero and a valid floating point numbervalue valueSpecifies how much of the task that has been completed. It should be a floating point number between 0 and max or 0 and 1 if max is omittedExampleYou can try to run the following code to learn how to create a ... Read More
In this article we will see how to find the frequency of each character in a given string. Then see if two or more characters have the same frequency in the given string or not. We will accomplish this in two steps. In the first program we will just find out the frequency of each character.Frequency of each characterHere we find the frequency of each character in the given input screen. We declare a empty dictionary and then add each character as a string. We also assign keys to each of the character to create the key-value pair needed by ... Read More
Use the tag to add a section in a document. The HTML tag is used for defining a section of your document. With the div tag, you can group large sections of HTML elements together and format them with CSS.ExampleYou can try the following code to create a section − HTML div Tag Welcome to our website. We provide tutorials on various subjects. The following is the css file style2.css#contentinfo p { line-height: 20px; margin: 30px; padding-bottom: 20px; text-align: justify; width: 140px; color: red; }