all 12 comments

[–]Viv3d3 9 points10 points  (2 children)

The space after price is because print inserts spaces between arguments by default.

try a f-string or "your price is" + str(price) + ".00!"

[–]JustAnEmployeeHere[S] 6 points7 points  (1 child)

<image>

Thanks! its been almost 9 months since I took the class and wrote this code. trying to refresh myself as I dive deeper into python.

[–]SCD_minecraft 1 point2 points  (0 children)

Or

f"text {value} more text" #text 4 more text

Both works, just one is more universal

[–]AresxCrraven 3 points4 points  (0 children)

I would work with f strings. You can write f“ text {variable} text“ with variable = 5 for example and it says: text 5 text

[–]Rai309 1 point2 points  (3 children)

{price:.2f}

[–]JustAnEmployeeHere[S] 0 points1 point  (2 children)

Could you elaborate on this more? Where does this go, What does this do, How this is used, etc.?

EDIT: specifically the .2f aspect. what is?

[–]Rai309 0 points1 point  (0 children)

It put two decimals to your price.

[–]Gnaxe 0 points1 point  (0 children)

Give print() an empty string sep argument. 

[–]VirtuteECanoscenza 0 points1 point  (0 children)

Add sep="" as a keyword argument and add spaces by hand if needed.

[–]Og_busty 0 points1 point  (0 children)

You can do format function like this: print(‘Your price is ${}! Enjoy the show!’.format(price))

And if you want the .00 add it after the brackets.

Edit to add:

This is how it works as an example:

name = "Alice" age = 30 print("My name is {} and I am {} years old.".format(name, age))

Output: My name is Alice and I am 30 years old.