title: Using function to minimize the amount of code
body: <p>I have a problem with my Python program. Let's say, I want to ask what is their favorite number between 1 and 100 to my students. So, I asked John and he replied that his is 1. Again, I asked Mark and he came up with 50 and so on. And then I also want to know their gender as well. Let's say John is a boy and Mark is a boy too. And I have 10 students in my class. What I want to do is keep a record like:</p>
  <pre class="lang-none prettyprint-override"><code>&lt;John - 1 - boy&gt;
  &lt;Mark - 50 - boy&gt;
  </code></pre>
  <p>So, I wrote some code like this:</p>
  <pre><code>while True:
      try:
          john_n = (int(input('Enter your favourate number : ')))
          if john_n &gt;= 100 or john_n &lt;= 0:
              print('Error!')
              continue
          else:
              john_n = str(john_n)
              break
      except ValueError:
          continue
  
  while True:
      try:
          john_g = (str(input('Are you boy or girl? : ')))
          if john_g == 'boy':
              std_g = 'boy'
              break
          elif john_g == 'girl':
              john_g = 'girl'
              break
          else:
              print('Please only answer \'boy\' or \'girl\'')
              continue
      except ValueError:
              print('Please only answer \'boy\' or \'girl\'')
              continue
  
  print(str('John\n'+'Fav No. '+john_n+'\nGender '+john_g))
  </code></pre>
  <p>It works, kind of. But I have another 9 students to go. I want to do it more effectively. So how can I do it? How to do it more effectively?</p>