Computer Science, asked by shivamchouhan07, 5 months ago

Write a function in Python POP(cities), where cities is a stack implemented by a list
of city names for eg. cities=['Delhi', 'Jaipur', 'Mumbai', 'Nagpur]. The function
returns the value deleted from the stack.​

Answers

Answered by pragatibhatt2922
1

Answer:

#love....

Explanation:

Python List Creation

List creation in Python is done by placing all the elements separated by commas, within a square bracket [ ]. As already mentioned above, a list can contain any number of items which can be of dissimilar types such as float, integer, string and so on. Below is an example for Python list creation:

# list of integers

my_list = [1, 2, 3] Python List that has another list within the same syntax as an item is called nested list. For example,

# nested listmy_list = [“mouse pad”, [8, 2, 6], [‘a’]]

Access elements from a Python List

Make use of index operator [] to access an item from a Python List. Index starts from ‘0’ and hence the first element is stored at 0th index in the list, second element at 1st index and it continues.

If you try to access the elements by any other method, IndexError will be raised. Note that all the index must be an integer.

In Python List, if you are using float or any other string types, the result would be

In Python List, you can use the Nested index to access the Nested list.

In Python List, you can use Slicing operator (colon) to access a variety of items.

Similar questions