advice please

v
Last edited on
You'd want to read in user input using a string instead of an integer since you are expecting either a number or a character. Once the user entered their input, you can check if it is a digit or not using the isdigit() method. Likewise, you can check if the input is an alphabet or not using the isalpha() method. If the input is a digit, you can store the value in your month variable. Otherwise, you store the character in a month letter variable. One easy way to check if the alphabet character is valid, you can create a temporary string that holds all the alphabets of the months. Then you can loop through the string and check if the user input is equal to any of the letters inside the string.
Topic archived. No new replies allowed.