Skip to content

Commit 78504ac

Browse files
Replace % with f-string in basics/modules.md (#40)
1 parent 22725a4 commit 78504ac

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

basics/modules.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ for thing in things:
369369
```
370370

371371
Measure how long it takes for the user to answer a question.
372-
The `%.2f` rounds to 2 decimals, and you can find more formatting
373-
tricks [here](https://pyformat.info/).
372+
The `{:.2f}` rounds to 2 decimals, and you can find more formatting
373+
tricks [here](https://docs.python.org/3/tutorial/inputoutput.html#formatted-string-literals).
374374

375375
```python
376376
import time
@@ -381,7 +381,7 @@ end = time.time()
381381
difference = end - start
382382

383383
if answer == '3':
384-
print("Correct! That took %.2f seconds." % difference)
384+
print(f"Correct! That took {difference:.2f} seconds.")
385385
else:
386386
print("That's not correct...")
387387
```
@@ -410,7 +410,7 @@ Check what a path points to.
410410
import os
411411
import sys
412412

413-
print("You are currently in %s." % os.getcwd())
413+
print(f"You are currently in {os.getcwd()}.")
414414

415415
while True:
416416
path = input("A path, or nothing at all to quit: ")

0 commit comments

Comments
 (0)