Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

only

Return a new list of strs that contains the strs from the original list converted to uppercase. actually i am not understand what is this question asking for.

  • 2 years ago
  • 2 years ago

  • This Question is Closed
  1. agdgdgdgwngo
    Best Response
    You've already chosen the best response.
    Medals 2

    This question is asking for you to generate a new list of strings from an old list of strings by converting each string to uppercase: transforming something like ["aaaa", "abab" , "acde"] into ["AAAA", "abab", "acde"]

    • 2 years ago
  2. agdgdgdgwngo
    Best Response
    You've already chosen the best response.
    Medals 2

    this is one line of Python: look at some str methods, and at the list comprehensions or the map function

    • 2 years ago
  3. only
    Best Response
    You've already chosen the best response.
    Medals 1

    def get_upper_list(orginal_list): '''Return a new list of strs that contains the strs from the original list converted to uppercase''' original_list = '' new_strs = get_upper_list(original_list) return new_strs so is this OK if write like this?

    • 2 years ago
  4. agdgdgdgwngo
    Best Response
    You've already chosen the best response.
    Medals 2

    that would be an infinite loop :-P http://ideone.com/2Jh2j

    • 2 years ago
  5. only
    Best Response
    You've already chosen the best response.
    Medals 1

    def get_upper_list(orginal_list): '''Return a new list of strs that contains the strs from the original list converted to uppercase''' original_list = [] list_strs = get_upper_list(original_list) return list_strs how about now?

    • 2 years ago
  6. agdgdgdgwngo
    Best Response
    You've already chosen the best response.
    Medals 2

    It's still an infinite loop: you are calling the function itself in the 5th line without a terminating condition

    • 2 years ago
  7. only
    Best Response
    You've already chosen the best response.
    Medals 1

    i have no idea now can you help me write down something ... i know this is ...

    • 2 years ago
  8. agdgdgdgwngo
    Best Response
    You've already chosen the best response.
    Medals 2

    http://docs.python.org/library/stdtypes.html#string-methods

    • 2 years ago
  9. agdgdgdgwngo
    Best Response
    You've already chosen the best response.
    Medals 2

    http://docs.python.org/tutorial/datastructures.html

    • 2 years ago
  10. keketsu
    Best Response
    You've already chosen the best response.
    Medals 0

    only, agdgdgdgwngo is right. What you have is a recursive function with no exit; it is going to continue calling itself forever. What you're probably looking for is something more like this: first_list = ['aaa','bbb','ccc'] upper_list = [] for item in first_list: upper_list.append(item.upper()) The work is done with a loop and the str.upper() command. If you were putting this into a function, it might look like: def make_upper(some_list): upper_list = [] for item in some_list: upper_list.append(item_upper()) return upper_list Notice here that the function is not calling itself. Now, you could conceivably use a recursive function, although it probably wouldn't be the right call for this task. It might look like this: def make_upper(some_list, upper_list): if some_list: ### as long as an item is still in some_list, recursive call upper_list.append(some_list.pop().upper()) make_upper(some_list, upper_list) ### the function is recursively calling itself return upper_list ### some_list is empty and upper_list is fully converted, return ### through all recursive levels some_list = ['aaa','bbb','ccc','ddd'] upper_list = [] get_list = make_upper(some_list, upper_list) get_list.reverse() ### this approach returns the list in reverse; set it right print get_list Hope that helps.

    • 2 years ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.