Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

I have the function which I am not able to edit, this function expects 3 arguments

def rgb_color(r,g,b):

    print(r,g,b)

now I have the values as the array, I can change this var if needed to the list or something

black = [0, 0, 0]

Is there any way to pass each variable black to the function without using

black[0], black[1], black[2]

something like this:

call_user_function(rgb_color, black) 

1 Answer

0 votes
by (36.8k points)

These are the possible solutions, it all depends on each exact behavior you're looking for.

This produces a correct output:

from bs4 import BeautifulSoup

html_src = \

    '''

    <html>

    <body>

    <div class="small subtle link">

        <a href="https://example.com" nofollow="" target='"_blank"'>

            Example

        </a>

        This text!

    </div>

    </body>

    </html>

    '''

soup = BeautifulSoup(html_src, 'lxml')

print(soup.prettify())

div_tag = soup.find(name='div', attrs={'class': 'small subtle link'})

div_content_text = []

for curr_text in div_tag.find_all(recursive=False, text=True):

    curr_text = curr_text.strip()

    if curr_text:

        div_content_text.append(curr_text)

print(div_content_text)

Want to be a master in Data Science? Enroll in this Data Scientist

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...