开发者

need help with a function problem

开发者 https://www.devze.com 2023-03-06 09:54 出处:网络
hi im in need of some help for some basic programming exercises im working through. here\'开发者_如何学Cs the problem.

hi im in need of some help for some basic programming exercises im working through. here'开发者_如何学Cs the problem.

a) Write a function that returns the maximum value from a list of names. The list of names is passed to the the function, the function returns the 'max' string.(essentially get the name that comes first alphabetically)

b) Write a function that replaces a value in a list with a different one. The parameters of this function are the list, the position in the list of the value that needs to be replaced and the replacement value. Call this function with alist of names in main(). Check if the list was changed by displaying it in main() after the replace function was called. (arrange the list alphabetically.)

in all of this i have to create two main programs, one main program to set up the basics then another seperate function to be called in the main to execute the necessary steps. it needs to be written in python. im completely lost here. heres the list of names im dealing with

bob
Nate
ethel
frank
johnjacobjingleheimerschmidt
clarice
ptolmey
nefertiti
hess
michelle
algernon


For part a), read how to use list.sort(). For part b), read this previous question on how to replace items in a list.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号