日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python简单菜单_创建一个简单的python菜单

發布時間:2023/12/3 python 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python简单菜单_创建一个简单的python菜单 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

修正和評論,它們主要是語法錯誤。menulist= '''1. Print the list,

2. Add a name to the list,

3. Remove a name from the list,

4. Change an item in the list,

9. Quit''' #assuming you want to display menulist, having it as a tuple is useless

lst=("johny","tom","kim","tim","jim") #don't use reserved names for variables, may mess up things

target=raw_input("Pick an item from the menu:")

if target=="1": #this is an equality operator, whereas = is used to assign a variable (This checks the equality basically)

print lst

elif target=="2":

Addname=raw_input("Type in a name to add:")

list=list.append(Addname) #use append instead of insert, insert is for a specific position in list

print menulist #no parentheses, menulist is not a function; also this doesn't have to be indented

elif target=="3":

Removename=raw_input("What name would you like to remove:")

list=list.remove(Removename)

print menulist #again, I took the parentheses away

elif target=="4":

Changename=raw_input("What name would you like to change:") #you'd missed the " at the beginning

changetoname=raw_input("What is the new name:")

list=list.replace(Changename, changetoname) #removed the '. They're the variables, not the strings 'Changename' etc that you want to replace.

print menulist

elif target=="9":

print"good bye" #excessive indenting

else: #this replaces the initial while

#do nothing if the initial input is not 1,2,3,4 or 9

print menulist

總結

以上是生活随笔為你收集整理的python简单菜单_创建一个简单的python菜单的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。