Knowee
Questions
Features
Study Tools

Write the output of the following code :L=list(https://logikworks.in/)print(L[20 : -1])

Question

Write the output of the following code :L=list(https://logikworks.in/)print(L[20 : -1])

🧐 Not the exact question you are looking for?Go ask a question

Solution 1

The code you've provided seems to be in Python, but it's incorrect. Python can't convert a URL directly into a list. If you want to convert a string into a list in Python, you need to put the string in quotes.

Here's the corrected code:

L = list('https://logikworks.in/')
print(L[20 : -1])

This code will output:

['.', 'i', 'n']

Here's the step by step explanation:

  1. The list() function is used to convert the string 'https://logikworks.in/' into a list where each character (including punctuation and slashes) is a separate element.

  2. The print() function is used to print a slice of the list from the 20th index to the second last index. In Python, list indices start at 0, and negative indices count from the end of the list. So L[20 : -1] will output the elements from the 20th index up to (but not including) the last element.

  3. The elements at indices 20, 21, and 22 of the list are '.', 'i', and 'n', respectively. So, the output of the code will be ['.', 'i', 'n'].

This problem has been solved

Solution 2

The code you've provided seems to be in Python, but it's incorrect. Python's list() function expects an iterable (like a string, tuple, etc.) as an argument. However, you're trying to pass a URL which is not a valid argument.

If you want to convert a URL string into a list of characters, you should pass the URL as a string to the list() function. Here is the corrected code:

L = list('https://logikworks.in/')
print(L[20 : -1])

This code will output a list of characters from the 20th index up to the second last element of the list L. The exact output will depend on the string you're converting to a list. In this case, the output will be:

['i', 'n', '/']

This is because the 20th character in the string 'https://logikworks.in/' is 'i', and the slice goes up to but does not include the last character, which is the closing slash '/'.

This problem has been solved

Solution 3

The code you've provided seems to be in Python, but it's incorrect. Python cannot convert a URL string directly into a list. If you want to convert a string into a list in Python, you can do it character by character.

Here's an example of how you can convert a string into a list:

L = list('https://logikworks.in/')
print(L[20 : -1])

This will output:

['.', 'i', 'n', '/']

This is because the list() function breaks the string into individual characters, and L[20 : -1] slices the list from the 20th index to the second last element.

This problem has been solved

Similar Questions

What is the output of the following code.l = [‘Logik', ‘works'] for i in l:     i.swapcase() print(l)

What will the output of the following line of code be?print(list(range(10, 1, -1)))

What will be the output of the following Python code? t=(10,20,40,30) print(t[1:-1])

What will the output of the following program be?L1 = ['Vikas', 'Akshay', 'Sanskar', 'Mahima']print(L1[1][-1])

What will be the output of the following code snippet?for index in range(20, 10, -3) :print(index, end = ' ')

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.