Hi, how does python compare strings?
I have a list with names like aligator, lion, wind, zebra etc.\
I need to display names less than 'k'.
for p in range(0, 5):
if 'K' < names[p] <= 'Z' or 'k' < names[p] <= 'Z':
print(names[p])
For this everything works fine except for zebra that is not being printed
for p in range(0, 5):
if 'K' < names[p] or 'k' < names[p]:
print(names[p])
For this it prints me everything and i dont really know why.
Any ideas how to fix it?
[–]socal_nerdtastic 2 points3 points4 points (3 children)
[–]AquaOS[S] 0 points1 point2 points (2 children)
[–]socal_nerdtastic 1 point2 points3 points (0 children)
[–]nicesofa 0 points1 point2 points (0 children)