Answers for "check var is list python"

0

python if variabl is list

from collections import UserList

regular_list = [1, 2, 3, 4, 5]
user_list = [6, 7, 8, 9, 10]

# Checks if the variable "a_list" is a list
if isinstance(regular_list, list):
    print("'regular_list' is a list.")
else:
    print("'regular_list' is not a list.")

# Checks if the variable "a_string" is a list
if isinstance(user_list, list):
    print("'user_list' is a list.")
else:
    print("'user_list' is not a list.")
Posted by: Guest on July-10-2021

Python Answers by Framework

Browse Popular Code Answers by Language