Python Forum

Full Version: Determine Number Fulfilling Three Inputs
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I have imported a csv list of superhero names, gender, eye color, hair color, and so on.
I ask the user to input their gender, eye color, and hair color.
After inputting each, they receive three messages.

Example:
Number of male characters: 11638
Number of characters with green eyes: 613
Number of characters with brown hair: 2339

How could I then take these three inputs and determine how many characters fulfill all three of the user inputs?
Please show your code to this point

Assuming that the text is in a string, it's simply len(Myvariablename)
then add together
(Mar-13-2017, 02:33 AM)Larz60+ Wrote: [ -> ]then add together

Wouldn't that give the result for how many characters fullfill any of the conditions? Or did I misunderstood?

Assuming that  the three already given responses are done by a check, it should be possible to do the check 'in a row' by combining if with and:
 if ... and if ... and if ...:
    add_to_number_of_characters_fullfilling_all_conditions
Quote:How could I then take these three inputs and determine how many characters fulfill all three of the user inputs?

How else to get sum of all 3?