You are not getting the expected output because in your code you say, "Hey python, print a comma if current element is not equal to last element."
Second element 9 is equal to last element, hence the comma is not printed.
The right way to check for the last element is to check the index of element :
a = ['hello', 9, 3.14, 9]
for item in a:
print(item, end='')
if a.index(item) != len(a)-1: #<--------- Checking for last element here
print(', ')
(Also, this might throw a value error. You should check for that too.)