Python 3.3 - Lists -


so i'm trying create state abbreviation list of first 10 states. easy enough (lest call list states1). want create second list using slicing outputs middle 4 states...still enough enough(we'll call list states2). ok part i'm getting messed on here.. want use function (lets name list_func) states2 being argument. within argument want delete second state in list, insert tx index 2, ask user random new state , append list, reverse list. here i've come far.. think have of correct i'm not sure on fine tuning...

def main():      states1 = ['al', 'ak', 'az', 'ar', 'ca', 'co', 'ct', 'de', 'dc', 'fl']     print(states1)     states2 = states1[3:7]     print(states2)      list_func in states2:         states2.remove('ca')         states2.insert(1,'tx')         user_st = input('enter new state: ')         states2.append(user_st)         states2.reverse()      print(states2)   main() 

given constraints of problem, work:

def main():     states1 = ['al', 'ak', 'az', 'ar', 'ca', 'co', 'ct', 'de', 'dc', 'fl']     print(states1)     states2 = states1[3:7]     print(states2)      list_func(states2)   def list_func(states):     states.remove('ca')     states.insert(1,'tx')     user_st = input('enter new state: ')     states.append(user_st)     states.reverse()      print(states)  main() 

list_func function, sole input being states2 list. when function called, things listed. did not use pop() mentioned have not covered yet


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

node.js - Express and Redis - If session exists for this user, don't allow access -