r/PythonLearning • • Aug 12 '25

Why not 4th!

Post image

In the fourth argument is the string "end1 ", then why is the correct answer the 1st one
This is a Codechef practice problem

11 Upvotes

14 comments sorted by

View all comments

2

u/NaiveEscape1 Aug 12 '25

Can anyone please tell me why it printed 5, isn’t that a integer data type as its not in quotes?

1

u/Temporary_Pie2733 Aug 12 '25

print is essentially just a wrapper around some file-like object’s write method, except it does a lot of processing of its arguments to produce the single str value expected by write. Part of that processing is to convert any non-str value to a str using its __str__ method.