I need to check if a value is a list before carrying out the rest of the code. The for loop should only be run if my_list is a list.
sum=0
if not list:
print("The input is not a list or is empty.")
exit()
for item in (list):
sum+=1
print("The length of the list is ",sum)
my_list = "Hello";
list_length(my_list)
The code works as expected when my_list is an actual list, but if I set it equal to a string, "Hello" at the moment in my code, the output is 5, I want it to not have an output.