我想要的是:
[1][2][3][4]
最后我得到了:
[1]、[2]、[3]、[4]]
我确实想看看它是否能工作,但我真的不知道,请帮忙,我已经为你发送了完整的代码 你们来看看发生了什么,帮我找到它的确切位置,因为我是一个完全的新手 关于python,我的朋友帮助我编写代码,但他也不知道
numeroIncorreto = True
continuaProcesso = True
lst_A = []
lst_B = []
while continuaProcesso:
while numeroIncorreto:
try:
n1 = int(input('Digite o primeiro número: '))
n2 = int(input('Digite o segundo número: '))
numeroIncorreto = False
except:
print('Favor digitar um número correto')
numeros = ''
if n2 >= 10 and n2 <= 50 and n1 >= 10 and n1 <= 50:
if n1>n2:
for i in range(n2, n1+1):
if i == n1:
numeros += str(i)
else:
numeros += str(i) + ' '
if i%2 == 0:
lst_A.append([i])
if str(i)[1] == '3' or str(i)[1] == '4': #
lst_B.append([i])
if n1<n2:
numeroD = n2
for i in range(n1, n2+1):
if numeroD == n1:
numeros += str(numeroD)
else:
numeros += str(numeroD) + ' '
if numeroD%2 == 0:
lst_A.append([numeroD])
if str(numeroD)[1] == '3' or str(numeroD)[1] == '4':
lst_B.append([numeroD])
numeroD -= 1
#Visualização na tela com devido espaço
print('\n'+numeros+'')
print('\nlst_A:')
print(lst_A)
print('\nlst_B:')
print(lst_B)
continuaProcesso = False
else:
print('Números fora do intervalo desejado.')
print('Numero 1: ' + str(n1))
print('Numero 2: ' + str(n2))
numeroIncorreto = True
试试
print(*lst_A)
和print(*lst_B)
首先将列表中的元素转换为字符串,然后连接元素
结果
相关问题 更多 >
编程相关推荐