1、问题背景
在python语言中,使用print()进行打印,默认是换行打印;如果要实现不换行打印,可以在print()添加第二个参数end=''
2、实现源码
nums = [12,34,45,64,77,89,90,21,34,54];
even = [];
odd = [];
i = 0;
while i < len(nums):
num = nums.pop();
if(num % 2 == 0):
even.append(num);
else:
odd.append(num);
print(even);
print(odd);
for i in 'ajdkasdkajkjfkaj':
print(i);
for i in [1,2,3,4,5,6,7]:
print(i,end='');
3、运行结果
E:PycharmProjectscmnvenvScriptspython.exe E:/PycharmProjects/cmn/venv/com.you.cmn/E.py
[54, 34, 90, 64, 34, 12]
[21, 89, 77, 45]
a
j
d
k
a
s
d
k
a
j
k
j
f
k
a
j
1234567
Process finished with exit code 0