I have the following code:
stuart = 0
kevin = 0
for itr, char in enumerate(word_list):
if char in "aeiou":
kevin += len(word_list) - itr
else:
stuart += len(word_list) - itr
Can I write the if/else statement as a ternary operator?
I tried the following to no avail:
(kevin if (char in "aeiou") else stuart) += len(word_list) - itr
and
kevin += len(word_list) - itr if char in "aeiou" else stuart += len(word_list) - itr
Is there a way to write this as a ternary operator for more compact code?