L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
name1 = L.pop(2)
name2 = L.pop(2)
print(L)
name1 = L.pop(2)
name2 = L.pop(2)
print(L)
2023-03-16
最新回答 / 天堂没有神
template1 = 'Life is {},'template2 = 'you need {a}'k423 = 'python'print(template1.format('short'),template2.format(a=k423))这样就可以
2023-03-15
最新回答 / qq_慕工程7590247
result = template.format(w=w , c=c , b=b, i=i )这一行要这样写,w=w,第一个w指template = 'Hello {w}, Hello {c}, Hello {b}, Hello {i}.'这里定义的形参,第二个指 w = 'World'这里定义的实参学了函数就知道了这个报错就是编译器找不到你定义的实参
2023-03-15
# coding: utf-8
a = '这是一句中英文混合的Python字符串'
b = 'Hello World!'
print(a +': '+ b)
chinese = '这是一句中英文混合的Python字符串'
english = 'Hello World!'
print (chinese + ':' + english)
s = r'''这是一句中英文混合的Python字符串:Hello World!'''
print(s)
a = '这是一句中英文混合的Python字符串'
b = 'Hello World!'
print(a +': '+ b)
chinese = '这是一句中英文混合的Python字符串'
english = 'Hello World!'
print (chinese + ':' + english)
s = r'''这是一句中英文混合的Python字符串:Hello World!'''
print(s)
2023-03-14
a = r'''"To be, or not to be":
that is the question.
Whether it's nobler in the mind to suffer.'''
print(a)
that is the question.
Whether it's nobler in the mind to suffer.'''
print(a)
2023-03-14
def square_of_sum(L):
a = [i**2 for i in L]
result = sum(a)
return result
L = [1,2,3,4]
x = square_of_sum(L)
print(x)
a = [i**2 for i in L]
result = sum(a)
return result
L = [1,2,3,4]
x = square_of_sum(L)
print(x)
2023-03-13
if not isinstance(x, int) or not isinstance(x, float):
这段代码应该使用逻辑运算符 and 而不是 or。这样,只有当 x 既不是整数也不是浮点数时,才会打印错误信息并返回 None
这段代码应该使用逻辑运算符 and 而不是 or。这样,只有当 x 既不是整数也不是浮点数时,才会打印错误信息并返回 None
2023-03-13
# Enter a code
N=['Alice', 'Bob', 'Candy', 'David', 'Ellena']
N[1]=N[3]
N.pop()
N.insert(0,'ELLENA')
print(N)
N=['Alice', 'Bob', 'Candy', 'David', 'Ellena']
N[1]=N[3]
N.pop()
N.insert(0,'ELLENA')
print(N)
2023-03-07