当前位置:   article > 正文

python学习日记

python学习日记

3-1姓名 print(name[].title())

name = [‘wangwei’,’weiguomeng’,’nidaye’]
print(name[0].title())
print(name[1].upper())
print(name[2].lower())

3-2问候语

print(“I’m very glad to meet you.”+name[0].title())
print(“I’m very glad to meet you.”+name[1].title())
print(“I’m very glad to meet you.”+name[2].title())

3-3自己的列表

food = [‘malatang’,’hongshaorou’,’latiao’]
print(“\nMy favorite food is”+food[0].lower())
print(“\nMy favorite food is”+food[1].lower())
print(“\nMy favorite food is”+food[2].lower())

3-4嘉宾名单

print(“\n”+name[0].title()+” I invite you to dinner with me!”)
print(“\n”+name[1].title()+” I invite you to dinner with me!”)
print(“\n”+name[2].title()+” I invite you to dinner with me!”)

3-5修改嘉宾名单

print(“\nI sorry,”+ name[0]+” can’t with me to dinner.”)
name[0] = ‘wangweiwei’
print(“\n”+name[0].title()+” I invite you to dinner with me!”)
print(“\n”+name[1].title()+” I invite you to dinner with me!”)
print(“\n”+name[2].title()+” I invite you to dinner with me!”)

3-6添加嘉宾

print(“The good news, I found a bigger table!”)
name.insert(0,’xiaoxingyun’)
name.insert(2,’xiaodaomei’)
name.append(‘kelianwa’)
print(“\n”+name[0].title()+” I invite you to dinner with me!”)
print(“\n”+name[1].title()+” I invite you to dinner with me!”)
print(“\n”+name[2].title()+” I invite you to dinner with me!”)
print(“\n”+name[3].title()+” I invite you to dinner with me!”)
print(“\n”+name[4].title()+” I invite you to dinner with me!”)
print(“\n”+name[5].title()+” I invite you to dinner with me!”)

3-7缩减名单

print(“because not timely sent to the table, so I can only invited two guests to dinner.”)
print(name)
name_1 = name.pop(0)
print(name_1+” I’m sorry can’t invite you to dinner!”)

name_1 = name.pop(0)
print(name_1+” I’m sorry can’t invite you to dinner!”)

name_1 = name.pop(0)
print(name_1+” I’m sorry can’t invite you to dinner!”)

name_1 =’weiguomeng’
name.remove(name_1)
print(name_1+” I’m sorry can’t invite you to dinner!”)

print(name)
print(name[0]+” I invite you to dinner.”)
print(name[1]+” I invite you to dinner.”)

del name[0]
del name[0]

print(name)

总结今天学习过程中出现的问题。
1.print里的变量message打错了。
2.添加元素使用instert()时语法错误,没有加 ‘。导致python解读不了。
3.使用pop()弹出元素时,没注意到上一行缺少个 )。导致文本器一直在提示无效语法。

自己要注意细心,加油!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/喵喵爱编程/article/detail/949794
推荐阅读
相关标签
  

闽ICP备14008679号