Hi guys...I'm new to python so I've no idea what I'm doing but I need to write a function that 1) asks the user how many strings they would like to input. 2)Stores the strings in a list 3) sorts the list 4) Displays the sorted list 5) Displays the shortest string 6) displays the longest string and 7) Displays the strings in the list that contain only alphabetic characters. I think i got the first 3 parts right...but that's as much as I've done.. I need to have it in the format below 2..so any help would be greatly appreciated. Thanks!
def makeList(num): alist= for i in range(num): x=input('Enter string please: ') alist.append(x) return alist def findShortest(lst): shortest= p=0 s="" for item in shortest: if(len(item)>p): s=item p=len(item) return s def findLongest(lst): def findAlpha(lst): def main(): num=input('Please enter the number of strings you want to input\n') lst=makeList(int(num)) lst.sort() print(lst) shortest=(findShortest(lst)) print(shortest) main()
Edited by Dani: Formatting fixed