Nov-09-2018, 03:18 PM
Hello , I'm a python beginner and I need help with For + Count.
I need to create a program that inputs a text , and then it count how many times the letter A, B, C appears in the text.
If A appears the most it needs to print a
If B appears the most it needs to print b
If C appears the most it needs to print c
If there isnt any a,c,b in the text or the 3 letters appear at the same amount it needs to print Balanced
I need help with the last IF i mentiond and I also need help with the 3 other IF'S because if I input 'ACC' it will print a and not c
I need to create a program that inputs a text , and then it count how many times the letter A, B, C appears in the text.
If A appears the most it needs to print a
If B appears the most it needs to print b
If C appears the most it needs to print c
If there isnt any a,c,b in the text or the 3 letters appear at the same amount it needs to print Balanced
I need help with the last IF i mentiond and I also need help with the 3 other IF'S because if I input 'ACC' it will print a and not c
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 or count_c: print 'a' elif count_b > count_a or count_c: print 'b' elif count_c > count_a or count_b: print 'c' else print 'balanced'I also tried using AND instead of OR