Skip to content

Commit

Permalink
Add new string formatting method, f-string
Browse files Browse the repository at this point in the history
  • Loading branch information
wwangwe committed Dec 8, 2020
1 parent 4c31c34 commit 3a5d79e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions source/week-1/variables/string-variables/f_strings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Only available for python 3.6+
# This new way of formatting strings lets you
# use embedded Python expressions inside string constants.

name = input("What is your name? ")
subject = input("What subject do you like? ")
print(f"{name}'s favorite subject is {subject}.")

a = 5
b = 10
sum = a + b
print(f'{a} plus {b} is equal to {sum}.')

0 comments on commit 3a5d79e

Please sign in to comment.