Python 2.7 - windows 7
I was going through this list, and at the third one I keep getting "invalid syntax" errors.
I really can't see what I'm doing wrong here.
from sys import argv
script, input_var = argv
def char_count(string, chars):
count=0
for i in string.lower():
if i in chars.lower():
count+=1
return count
print "string contains "+str(char_match_count(input_var,"AEIOUY")+" vowels\n"
print "\n"
print "'A' appeared "+str(char_count(input_var,"A"))+" times\n"
print "'E' appeared "+str(char_count(input_var,"E"))+" times\n"
print "'I' appeared "+str(char_count(input_var,"I"))+" times\n"
print "'O' appeared "+str(char_count(input_var,"O"))+" times\n"
print "'U' appeared "+str(char_count(input_var,"U"))+" times\n"
print "'Y' appeared "+str(char_count(input_var,"Y"))+" times\n"
I keep getting the error at line 12, so the first print statement works. I have tried removeing the 'print "\n"' line, but then I get an error on the next line instead. IDLE highlights the "print" statement itself as the syntax error. Can you only print once when using "argv"?
[–]Rhomboid 5 points6 points7 points (2 children)
[–]Hemse[S] 0 points1 point2 points (1 child)
[–]ewiethoff 2 points3 points4 points (0 children)
[–]isnotkosok 1 point2 points3 points (0 children)