I'm already using elif not re.match("^[a-z]*$", first_name)
, but every time I enter a capital letter for the name, it returns the message I use if they are using anything other than a letter in the alphabet. Thank You in advance for any help you can give.
Asked
Active
Viewed 728 times
-2
-
2Just a check, can't you simplify this approach by lowering the case of the word? Or by making it go upper? Maybe it's a more simple solution – Alexander Santos Dec 05 '19 at 16:07
-
Could you share the code in question? – Aquarthur Dec 05 '19 at 16:07
-
1If you want to use both uppercase and lowercase, you should change the regex to `re.match("^[a-zA-Z]*$", first_name)` – pecey Dec 05 '19 at 16:10
-
to check if the first char of a string `s` is uppercase, just use `s[0].isupper()`. – FObersteiner Dec 05 '19 at 16:10
-
Thank you @pecey that helped a lot. I will check to see if I can use everyone else's suggestions to help simplify the code I already have. – Mark Nova Dec 05 '19 at 16:26
1 Answers
0
For lower case:
s1 = input().lower()
and for upper case:
s1 = input().upper()
This should just work fine. All it is doing is converting the input to either upper
or lower
case as specified.
Hope this helps :)

Debdut Goswami
- 1,301
- 12
- 28