Python 3 Tutorial: 18 – Formatting


Video is ready, Click Here to View ×

Learn how to format strings using .format()!

33 thoughts on “Python 3 Tutorial: 18 – Formatting

  1. What's the difference between the "f" and the "d" and does the decimal before this matter?
    Eg. {:3f) or {:.3f}
    Is this decimal necessary? And if so, how come it wasn't used in the "d" example?

  2. @SMERSH009X input() in Python 3 is the exact same as raw_input() in Python 2. To use Python 2's input() in Python 3 you can use something like eval(input())

  3. @SteakOfAnger I think the problem is with the input method in python 3. your code seems to be fine. Try doing it in python 2 and use raw_input instead of input. it should work.
    you have to use a method to remove the extra whitepace that python 3 adds to your user's input string, i think it's either strip or rstrip or something similar. Your best bet is to post your question on stackoverflow . good luck!

Leave a Reply

Your email address will not be published. Required fields are marked *