GPYC Exam QuestionsBrowse all questions from this exam

GPYC Exam - Question 23


What is the output when the following commands are typed in Python interactive mode?

Show Answer
Correct Answer: AD

The output of the command re.findall(r"tag.*tag", "i want tag to go tag to sans tag") in Python is ['tag to go tag to sans tag']. The regular expression r"tag.*tag" matches the shortest string that starts with "tag" and ends with "tag", including everything in between. In this case, the entire substring "tag to go tag to sans tag" is matched.

Discussion

5 comments
Sign in to comment
bighead12Option: D
Jul 16, 2022

D. I ran the code :)

k4ziOption: D
Aug 1, 2023

Yeah thought it was wrong and confirmed as bighead12 did. The answer is D.

NASCAROption: D
Aug 10, 2023

Answer is D. There isn't a comma in the string either. Python confirms this.

matts5150Option: D
Jan 28, 2024

ran code

a29dc2cOption: D
Feb 7, 2024

D is the answer