Flash Sale: Flat 70% + Addl. 25% Off on all Courses | Use Coupon DS25 in Checkout | Offer Expires In

  Enroll Now

Lists

A list in Python is a sequence of values. Unlike strings which are a group of characters, a list can have any data type. It can also be a group of different data types at once which can be list type as well. For eg,

a = [12, 3.4, 34, 'cloudxlab', [2.3, 1.4]]
print(a)

It prints [12, 3.4, 34, 'cloudxlab', [2.3, 1.4]]

A list within another list is nested. Although a list can contain another list, the nested list still counts as a single element. A list that contains no elements is called an empty list. We can create one with empty brackets, [].

Lists are mutable unlike strings.

Therefore, we can write something like this,

a[1] = 4
print(a)

The value at index 1 and it prints [12, 4, 34, 'cloudxlab', [2.3, 1.4]]. For lists also, the indexing starts from 0.

INSTRUCTIONS
  • Execute this code in the notebook a = [12, 3.4, 34, 'cloudxlab', [2.3, 1.4]]
  • The output of print(3 in a) is
  • Execute this code in the notebook print('cloudx lab' in a)
  • The output of print('cloudx lab' in a) is

No hints are availble for this assesment

Answer is not availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...