[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?
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
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
Louis thanks man 👍
thanks guys one more question. is there a way to put zeros to the right of the string?
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
Muna what do you need help with?
Muna what is your question?
Cornbred unfortunate but they are a part of all internet sites like this.
#! /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 = ""
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.
a.zfill(6) zfill means zero fill so a is equal to solo; solo is 4 words.then add 2 zero. thank You
I thought about
NameError: name 'l' is not defined
i need help