Hello everyone I am of course new to ppython and I am having trouble joining an integer variable and a string without a space in between them. Lets say my variabe was an integer of num = 121 and I wanted to print the proper ending of "st". which would make it 121st how would I go about it? Here is my code it works fine accept for an unwanted space.
num = input("Please enter a number : ")
numin = int(num)
while (num > 100):
num = num - 100
if num == 1 or num > 20 and num % 10 == 1:
print str(numin) ,("st")
elif num % 10 == 2 and num > 20 or num == 2:
print str(numin), ("nd")
elif num % 10 == 3 and num > 20 or num == 3:
print str(numin), ("rd")
elif num % 10 == 4 or num % 10 == 5 or num % 10 == 6 or num % 10 == 6 or num % 10 == 6 or num % 10 == 7 or num % 10 == 8 or num % 10 == 9 or num % 10 == 0 or num == 11 or num == 12 or num == 13:
print str(numin), ("th")
Here is what my ouput looks like, Also if anyone see any syntax errors that I have made feel free to correct me. I don't want to develop bad habits. Thanks in advance
Please enter a number : 121
121 st
================================ RESTART ================================
Please enter a number : 145
145 th
================================ RESTART ================================Please enter a number : 735
735 th
================================ RESTART ================================Please enter a number : 32
32 nd
================================ RESTART ================================Please enter a number : 33
33 rd