Convert List of Strings to List of Lists in Python

Pradeep Elance
Updated on 03-Mar-2020 06:34:31

976 Views

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

Python cmp() Method

Pradeep Elance
Updated on 03-Mar-2020 06:30:00

4K+ Views

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

Define an Area in an Image Map with HTML

Abhinanda Shri
Updated on 03-Mar-2020 06:28:47

514 Views

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

Clearing List as Dictionary Value in Python

Pradeep Elance
Updated on 03-Mar-2020 06:27:16

170 Views

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

Make Text Blink with HTML

Ramu Prasad
Updated on 03-Mar-2020 06:25:20

221 Views

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    

Display Text Ruby Annotation in HTML5

Anvi Jain
Updated on 03-Mar-2020 06:23:49

292 Views

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)          

Set What Browsers Show for Unsupported Ruby Element

V Jyothi
Updated on 03-Mar-2020 06:22:50

154 Views

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)          

Create a Progress Bar in HTML

Prabhas
Updated on 03-Mar-2020 06:22:08

7K+ Views

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

Check If Frequencies of All Characters in a String Are Different

Pradeep Elance
Updated on 03-Mar-2020 06:21:19

212 Views

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

Create a Section in a Document in HTML

Jennifer Nicholas
Updated on 03-Mar-2020 06:20:17

10K+ Views

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; }

Advertisements