[Pythonmac-SIG] inputing multi-digit numbers

Henning.Ramm@mediapro-gmbh.de Henning.Ramm at mediapro-gmbh.de
Thu Nov 10 15:35:37 CET 2005


> Thank you. That gives me something closer to a list, but the output is now: ['939\n', '936\n', '937\n', '885\n', '886\n', '887\n', '171\n', '19\n', ...]

> Question: how do I get rid of the \n attached to each member in my list?

Choose:

map(int(map(string.strip, yourlist)) (Python 2.2)

[ int(x.strip()) for x in yourlist ] (Python 2.3)

( int(x.strip()) for x in yourlist ) (Python 2.4)


Best regards,
Henning Hraban Ramm
Südkurier Medienhaus / MediaPro
Support/Admin/Development Dept.


More information about the Pythonmac-SIG mailing list