Write the code in python to define a function has_repeat(mystr), which takes a string parameter and returns a boolean result. - If mystr has a character that is repeated (count is more than 1 for that character), return True - Otherwise, return False Hint: You can solve this problem by iterating over the characters in mystr and comparing each character's count with 1. For example: Test Result print(has_repeat("Happy")) True print(has_repeat("sad")) False print(has_repeat("salmons")) True print(has_repeat("Trouts")) False
Write the code in python to define a function has_repeat(mystr), which takes a string parameter and returns a boolean result. - If mystr has a character that is repeated (count is more than 1 for that character), return True - Otherwise, return False Hint: You can solve this problem by iterating over the characters in mystr and comparing each character's count with 1. For example: Test Result print(has_repeat("Happy")) True print(has_repeat("sad")) False print(has_repeat("salmons")) True print(has_repeat("Trouts")) False
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.5: A Closer Look: Loop Programming Techniques
Problem 12E: (Program) Write a program that tests the effectiveness of the rand() library function. Start by...
Related questions
Question
Write the code in python to define a function has_repeat(mystr), which takes a string parameter and returns a boolean result.
- If mystr has a character that is repeated (count is more than 1 for that character), return True
- Otherwise, return False
Hint: You can solve this problem by iterating over the characters in mystr and comparing each character's count with 1.
For example:
Test | Result |
---|---|
print(has_repeat("Happy")) | True |
print(has_repeat("sad")) | False |
print(has_repeat("salmons")) | True |
print(has_repeat("Trouts")) | False |
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 4 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr