Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
can I delete ":"?
the code is >>>name=input("č¾å „å§å") č¾å „å§å:éé >>>print("{ }å„å„ļ¼å¦å„½Python,äŗŗč§äŗŗē±ļ¼".format(name[1:]))
8 Respostas
+ 6
No, you can't, name[1:] is the whole string without the first element, but name[1] is just the second element
+ 5
Mirielleš¶ [Inactive] I know you made a simple typo but, as it's potentially a confusing one, I feel I should correct.
If name = "xiao"
name[1:] is "iao"
name[1] is "i"
+ 3
You can remove the : using slice function, even though might not be the solution you searched for:
name[slice(1, None)]
+ 3
To delete ":",
you must have a replace function on a string object.
print("{} blahblahblah".format(name.replace(':',''))
+ 1
thank u,Airree but why this code without ":"?
>>>print("{ }å¤§ä¾ ļ¼å¦å„½Python,大å±ę³čļ¼".format(name[0]))
0
No, name[1:] is the whole string except the first element, name[0] is just the first element
- 1
Hi
- 3
mirie love you