###### tags: `homework` # homework 19 ## 19 - 1 ```python= import random list_num = [] strlist = [] def newlist(): for i in range(5): list_num.append(random.randrange(1, 11)) i += 1 return list_num def alist(): # 括弧、カンマなしリスト for i in range(5): strlist.append(str(list_num.pop(0))) #intからstrのリストへ i += 1 a = " ".join(strlist) return "List:" + a print(newlist()) print(alist()) def blist(x): for i in range(x): strlist.append(str(list_num.pop(0))) #intからstrのリストへ i += 1 a = " ".join(strlist) return "List:" + a def add(): x = int(input("Please enter how many to add () : ")) for i in range(x): y = int(input("New number (新しい数字) : ")) list_num.append(y) i += 1 return blist(x) def insert(): x = int(input("Please enter how many to insert () : ")) y = int(input("Insert position (The first position is 1)[挿入位置 (最初の位置は 1) ]: ")) for i in range(x): z = int(input("New number (新しい数字) : ")) list_num.insert(y, z) i += 1 return blist(x) def delete(): x = int(input("Delete number(削除された値): ")) list_num.remove(x) return blist(x) print("1.Add(追加) 2.Insert(挿入) 3.Delete(削除) 4.End") select = int(input("Please select function(機能を選択してください): ")) while select != 4: if select == 1: print(add()) select = int(input("Please select function(機能を選択してください): ")) elif select == 2: print(insert()) select = int(input("Please select function(機能を選択してください): ")) elif select == 3: print(delete()) select = int(input("Please select function(機能を選択してください): ")) else: print("No option") select = int(input("Please select function(機能を選択してください): ")) else: print("End") ``` deleteの関数ができていないのと,insertの関数に欠陥があります 時間をかなりかけましたがわかりませんでした