1

Result must include the delimiter.

Ex: a='1,000' of type string and the output must be: a=1,000 as an integer.

3

1 Answer 1

2

An integer won't include a comma. It's only for making the number readable that you add commas to it.

If you meant you want to parse the string into an integer, you should do the following:

num = int(a.replace(',', ''))

Afterwards if you want to present this integer with a comma again, you should just:

print "{:,}".format(num)

For back and fourth conversion in execution: Format and replace can help

Sign up to request clarification or add additional context in comments.

1 Comment

This is useful if you have to stay on , as delimiter. Otherwise Chris_Rands comment is the way of doing it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.