Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

Output from dict to list then string: newText = list() for i in range(len(text)): newText.append(coder[text[i]]) return ''.join(newText) is there a way to directly make a string from a dict rather than making a list first?

MIT 6.00 Intro Computer Science (OCW)
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer

SIGN UP FOR FREE
You can access the values of a dict as a tuple using this method: dict.values(). return ''.join(dict.values())
I forgot to add that TEXT is a string, and CODER is a dict. What I'm looking for is a way to extract dict values to a string based on some rule. This would seem to be a really basic method, since you can't assign values to an existing string. The values() method just gets all values. I could make a dictionary with the values I want and then use the values method, but I was hoping there is a way to make a string based on a rule directly.
newText = '' for i in range(len(text)): newText += coder[text[i]] return newText I think this concatenation will work, but I wonder if it is more or less efficient.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Not the answer you are looking for?

Search for more explanations.

Ask your own question