Oct-19-2023, 06:49 PM
Hi all,
The .index() and .count() functions are being called in both programs but in the first, the second function return replaces the first function return. How would I explain this observation in pythonic terms?
Thanks!
list1 = ["cat", "dog", "cat", "dog"]
list1.index("cat")
list1.count("dog")If I enter that in a Jupyter Notebook cell then the output is: 2list1 = ["cat", "dog", "cat", "dog"]
print(list1.index("cat"))
print(list1.count("dog"))If I enter that in a Jupyter Notebook cell then the output is 0 with 2 on the very next line.The .index() and .count() functions are being called in both programs but in the first, the second function return replaces the first function return. How would I explain this observation in pythonic terms?
Thanks!
