+ 22
[SOLVED] Can you please explain this code?
I was doing a challenge, and I got this question. what is the output of this code? a = solo print(a.zfill(6)) the output was 00solo why?
26 ответов
+ 31
https://www.programiz.com/JUMP_LINK__&&__python__&&__JUMP_LINK-programming/methods/string/zfill
The zfill() method returns a copy of the string with '0' characters padded to the left.
The word 'solo' is 4 letters long
zfill(6) fills it with zeroes from the left till it is 6 long.
Hence Zero fill -> zfill
+ 19
str.zfill(n) adds 0 to left until total length is n
str.rjust(n, char) adds char (default is a space) to left until total length is n
str.ljust(n, char) is like rjust but adds char to right
str.center(n, char) adds char both sides (first right then left side) until total length is n
+ 10
Louis thanks man 👍
+ 8
thanks guys
one more question.
is there a way to put zeros to the right of the string?
+ 6
the zfill() method pads the word with zeros on the left so zfill(6) sets the space to take up to 6 so if a was empty and you printed it it would show
000000
but since a =solo
it displayed:
00solo
+ 5
Muna what do you need help with?
+ 5
Muna what is your question?
+ 5
Cornbred unfortunate
but they are a part of all internet sites like this.
+ 2
#! /usr/bin/python
#apt install linux
import subpross
import sys
import os
jaid = input("enter install (y/n)
if jaid == "y":
subprocess.Popen('apt install websploit', stdout=subprocess.PIPE, stderr=subprocess.PIPE shell=True)
hg = os.path.exists('/usr/share/webploit/')
jaider = ""
+ 2
my question
+ 2
+ 2
LONGTIE👔
😂🤣😂🤣
+ 2
Since the registration is open to anyone not surprise that scammer or two would show up. The cruddy part is that their attempting such on a beginners/learners site, so not sure exactly what they would gain $$ wise. Its unfortunate but through experience, there's been a pattern with the ones with bad english and no different than those "specialist" call-center that litter the web with cheesy alert() boxes.
Don't see too many if hardly any of them on other IT forums, however, as their mostly populated with other devs who would immediately ban the scammer/bot accounts.
+ 2
a.zfill(6)
zfill means zero fill so a is equal to solo; solo is 4 words.then add 2 zero.
thank You
+ 1
I thought about
+ 1
NameError: name 'l' is not defined
0
a
- 1
i need help
- 1
I