
[英]How do I compare a character to all the characters in some string in Python?
[英]Duplicate some of the characters and all the characters in a string, using the character's indexes
我想知道是否可以使用索引来复制字符串中的字符。 我有一个示例 function 作为解决方案,但我正在寻找一个可以使用索引复制“str”字符的答案。 知道如何复制一些角色也会很有趣。 我希望我能很好地解释自己,并感谢您的所有答案!
word1 = 'The'
word2 = 'AAbb'
def double_char(word1):
to_return = ''
for x in word1:
to_return += x * 2
return to_return
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.