+ 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
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
+ 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)
+ 2
Okay, thanks everyone!