python if variabl is list

Solutions on MaxInterview for python if variabl is list by the best coders in the world

showing results for - "python if variabl is list"
Beatrice
10 Sep 2016
1from collections import UserList
2
3regular_list = [1, 2, 3, 4, 5]
4user_list = [6, 7, 8, 9, 10]
5
6# Checks if the variable "a_list" is a list
7if isinstance(regular_list, list):
8    print("'regular_list' is a list.")
9else:
10    print("'regular_list' is not a list.")
11
12# Checks if the variable "a_string" is a list
13if isinstance(user_list, list):
14    print("'user_list' is a list.")
15else:
16    print("'user_list' is not a list.")