I am trying to learn python, I was trying write C/C++ code i used before in python, can anyone help me find whats wrong in this code....
#print 1st for 1 -> st or 2nd for 2 -> nd , etc
x = int(input('Enter a number :'))
temp = x
while temp>0:
temp = temp % 10
if temp == 1:
print (x, "st")
elif temp == 2:
print (x, "nd")
elif temp == 3:
print (x, "rd")
else:
print (x, "th")
and can you suggest few goods books to learn python, for now i was reading the documentation and its not for beginners...and i know C/C++
print (3, "rd")outputs3 rd. Use e.g.print(x, "rd", sep='')to avoid that space.