擅长:python、mysql、java
<p>字符串是不可变的,您必须创建一个新变量并将结果添加到其中</p>
<pre><code>newPhoneNum="" #new empty variable to add the result to
var = phoneNum[1:2] #extract the part of the phone that you will use
for index in len(var)):
if var[index] == 'A' or var[index] == 'B' or var[index] == 'C':
newPhoneNum+='2'
.
.
etc
print(phoneNum[0]+newPhoneNum)
</code></pre>