Python: How To Print Non String Array?
I'm pretty new to python, and I wonder how I can print objects of my class fracture. The str funcion is set properly, I guess def __str__(self): if self._denominator == 1:
Solution 1:
If you want to print "1 < 2 < 3" all you need to do is change the type from an int to a string as such:
print(' < '.join(str(n) for n in (1,2,3)))
Solution 2:
You have to convert the ints to strings first:
numbers = (1, 2, 3)
print(' < '.join(str(x) for x in numbers))
Solution 3:
Solution 4:
You can convert integers to string.
print(' < '.join((str(1),str(2),str(3))))
Post a Comment for "Python: How To Print Non String Array?"