我的代码:
exampleA= input("Give me an ExampleA\n") #hello
exampleB = input("Give me an ExampleAB\n") #<- here you should be able to write 50, 70, 80
for x in exampleA and exampleB:
print("nice" + exampleA) #<- i get nicehello
print("for" + exampleB) #
所以我想对示例B中的每个元素 另一个打印,但我得到这个输出
nicehello
for50,70,80,90,20
nicehello
for50,70,80,90,20
nicehello
for50,70,80,90,20
但是我想要
nicehello
for50
nicehello
for70
nicehello
for80
顺便说一下,我是python的初学者
正如你所说:
它不会将其拆分为拆分您应该使用变量“x”
实际上,您需要拆分字符串,然后迭代字符串的元素:
输出:
以这种方式将代码更改为:
相关问题 更多 >
编程相关推荐