What is the output of the following Python code snippet?
from pathlib import Path
print(Path('file.txt').suffix[1:])
print(Path('file.txt').suffix[1:])
Correct answer
B. txt
7 views
B. txt
7 views
pathlib.Path.suffix returns the extension including the dot, and suffix[1:] removes the dot.
Asked in: Python Interview Standard Library
https://docs.python.org/3/library/index.htmlNot sure why the answer is B? Ask here and get an explanation.