[英]How to print out a string of a '&', equal to the length of a list
I want to print out a list of the character '&' as many times as there are in a given number. 我想打印一个字符“&”的列表,次数与给定数字相同。 So if the number is 10, I want the result to be '&&&&&&&&&&&'
因此,如果数字为10,我希望结果为'&&&&&&&&&&'
What I have done is turned the int into a list so I can better visualize what I want to perform. 我所做的就是将int转换为一个列表,这样我可以更好地可视化我想要执行的操作。
def print_list_&(size):
"""super serious docstring"""
result_1 = 1
result_2 = size + 1
result = list(range(result_1, result_2))
return result
I'm stuck on where I go from here. 我被困在从这里去的地方。 This is university work so I'm better off with a push in the right direction than a straight answer.
这是大学的工作,所以与正确的答案相比,向正确的方向发展最好。
'&' * 10
will give you '&&&&&&&&&&'
. '&' * 10
将给您'&&&&&&&&&&'
。 Therefore it seems you just need '&' * size
. 因此,似乎您只需要
'&' * size
。
Python 2: Python 2:
N = int(raw_input())
print '&' * N
Python 3: Python 3:
N = int(input())
print ('&' * N)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.