Python Forum
Check if string is uppercase or lowercase and eliminate
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Check if string is uppercase or lowercase and eliminate
#2
isupper is a function not an attribute so it needs parenthesis
>>> "Fred".isupper
<built-in method isupper of str object at 0x0348DEC0>
>>> "Fred".isupper()
False
>>> "Fred"[0].isupper()
True
Also you should be using for loops for this, not while loops:
code = "soMe SuPPLies liKE Ice-cREAm aRe iMPORtant oNly tO THeir cReaTORS. tO DestroY thEm iS pOInTLess"

for word in code.split():
    if word[0].isupper():
        print(word)
Reply


Messages In This Thread
RE: Check if string is uppercase or lowercase and eliminate - by Mekire - Jan-01-2018, 05:03 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Sad Check if a given string has its open brackets closed by the same type of brackets? noahverner1995 1 1,252 Apr-11-2022, 02:13 PM
Last Post: deanhystad
  Using re to find only uppercase letters ranbarr 6 3,288 May-31-2021, 03:19 PM
Last Post: ranbarr
  Uppercase problem MarcJuegos_YT 4 2,621 Aug-21-2020, 02:16 PM
Last Post: MarcJuegos_YT
  Finding Number of Lowercase letters in a Set Steven 6 5,139 May-26-2017, 03:11 PM
Last Post: Steven

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020