Featured Post

Scraping Website: How to Write a Script in Python

Here's a python script that you can use as a model to scrape a website. Python script The below logic uses BeautifulSoup Package for web scraping. import requests from bs4 import BeautifulSoup url = 'https://www.example.com' response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') # Print the title of the webpage print(soup.title.text) # Print all the links in the webpage for link in soup.find_all('a'):     print(link.get('href')) In this script, we first import the Requests and Beautiful Soup libraries. We then define the URL we want to scrape and use the Requests library to send a GET request to that URL. We then pass the response text to Beautiful Soup to parse the HTML contents of the webpage. We then use Beautiful Soup to extract the title of the webpage and print it to the console. We also use a for loop to find all the links in the webpage and print their href attributes to the console. This is just a basic example, but

How to Use List Function in Python

Here's is an answer to calculate the length of the repeated lists. LIST is a principle data type in Python that holds a list of values. Usually strings.

List() Function the Real Usage

You can do various operations with Lists. The best examples are REPEAT, APPEND, INSERT, EXTEND, COUNT. Still more you can do.

Note: This question is from a test recently held by an HR company. HR firms usually ask to take an online test to filter the job-seekers.

You can find list length using list() and len() functions


1. Question
2. How to Find Length

Interview Question 

The '* 2' says times the list is repeated. In this question, they have given '2' times.

my_list = ['srini', 'seetha', 'rao']
b = len(list(list(list(list(list(my_list*2))))))
Print (b)

Select Answer

1. 5
2. 6
3. 7
4. None


  • In the first step, the '*' says, you repeated the List two times.
  • It confuses the test-taker since they have given multiple functions of the list().

How to get Length

You can code the way I did. So that you can get the length correctly. So, the answer to the question is '6'. The List is repeated twice. There's no effect of multiple lists on the list.

Result (Ubuntu Linux OS)

At the command level, the given question entered. After pressing enter, it showed the result as '6'. That means the list (which has initially '3' elements') doubled. So the list length is now '6'.

Result of Python List


  1. Here're the best examples on Python List
  2. Here's the complete list for your reference.


Popular posts from this blog

7 AWS Interview Questions asked in Infosys, TCS

How to Decode TLV Quickly