+ 1

Can someone explain this please?

I got this question in a challenge, and am confused by the answer. Could someone explain it to me please? Code: What is the output of this code? a = 'solo' Print (a.zfill(6)) Answer: 00solo

13th Jul 2020, 2:15 AM
A.13S.
3 Answers
+ 5
The length of a is 4 characters. Using a.zfill(6) will make the length 6 by adding 0’s to the start of the string. https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/ref_string_zfill.asp
13th Jul 2020, 2:17 AM
Rowsej
Rowsej - avatar
+ 2
The zfill() method returns a copy of the string with '0' characters padded to the left. The syntax of zfill() in Python is: str.zfill(width)
13th Jul 2020, 2:20 AM
SùñtÎsh
SùñtÎsh - avatar
+ 2
Okay, thanks everyone!
13th Jul 2020, 2:21 AM
A.13S.