# ChapterLists/readList.py """ 0 enter a name? ann 1 enter a name? dan 2 enter a name? ben ann dan ben anndanbenanndanben List(type 2, 3, 4)? 2,3,4 LL = [2, 3, 4] """ def readList(): L=input("\nList(type 2, 3, 4)? ") #list? 2,3,4 # L = '2,3,4' M = L.split(',') # becomes ['2', '3', '4'] M = [int(x) for x in M] # [2, 3, 4] return M def main(): L = [] # initailize empty list n = 3 # get n strings from user and append them to the list for i in range( n ): name = input( str(i) +" enter a name? " ) L.append( name ) for x in L: # BEST: no need to use index print(x) for i in range( n ): # print list, one string at a time print(L[i],end="") for i in range(len(L)): # print by index print(L[i],end="") LL = readList() # reads the list as a sequnce of elements separated by comma print("LL=",LL) main()