Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If + Count
#3
Is this what you mean?
text = raw_input ('Enter a text:')
count_a = 0
count_b = 0
count_c = 0
for letter in text:
    if letter == 'a':
        count_a += 1
    if letter == 'b':
        count_b += 1
    if letter == 'c':
        count_c += 1
if count_a > count_b and count_c:
    print 'a'
elif count_b > count_a and count_c:
    print 'b'
elif count_c > count_a and count_b:
    print 'c'
else
    print 'balanced'
Reply


Messages In This Thread
If + Count - by Itay - Nov-09-2018, 03:18 PM
RE: If + Count - by ichabod801 - Nov-09-2018, 03:19 PM
RE: If + Count - by Itay - Nov-09-2018, 03:23 PM
RE: If + Count - by nilamo - Nov-09-2018, 06:36 PM
RE: If + Count - by Itay - Nov-09-2018, 09:18 PM
RE: If + Count - by nilamo - Nov-09-2018, 09:57 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Count Letters in a Sentence (without using the Count Function) bhill 3 5,276 Jun-19-2018, 02:52 AM
Last Post: bhill

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020