Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Check if string is uppercase or lowercase and eliminate
In the war against Skynet, humans are trying to pass messages to each other without the computers realising what's happening.

To do this, they are using a simple code:

They read the words in reverse order
They only pay attention to the words in the message that start with an uppercase letter
So, something like:

BaSe fOO ThE AttAcK
contains the message:

attack the base
However, the computers have captured you and forced you to write a program so they can understand all the human messages (we won't go into what terrible tortures you've undergone). Your program must work as follows:

code: soMe SuPPLies liKE Ice-cREAm aRe iMPORtant oNly tO THeir cReaTORS. tO DestroY thEm iS pOInTLess.
says: destroy their ice-cream supplies

Notice that, as well as extracting the message, we make every word lowercase so it's easier to read.

This is what I have written so far...
code=input("code: ")
while b<a:
  if c.isupper:
  elif c.islower:
['BaSe', 'fOO', 'ThE', 'AttAcK'] 4 ['BaSe', 'fOO', 'ThE', 'AttAcK']
I need the last line to say "BaSe ThE AttAck" eliminating "fOO" and I will be reversing the string in the last step to make sense, but it is not differentiating between a lowercase word and an uppercase word.
Please help. Thanks
isupper is a function not an attribute so it needs parenthesis
>>> "Fred".isupper
<built-in method isupper of str object at 0x0348DEC0>
>>> "Fred".isupper()
>>> "Fred"[0].isupper()
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():

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  sending arduino data to python and use a parity check 10_Lucas 6 264 Aug-03-2019, 10:37 AM
Last Post: DeaD_EyE
  Please check code Evgeniy2019 4 281 Apr-05-2019, 06:37 PM
Last Post: Evgeniy2019
  How to check an array exist in a file using Python fitrisibarani 17 760 Feb-27-2019, 04:16 PM
Last Post: ichabod801
  Hi how to take row 1 for every column and check the value what class is it kirito85 2 483 Nov-21-2018, 06:52 AM
Last Post: kirito85
  Check if integer is between two values Wolfpack2605 3 14,957 Dec-24-2017, 06:39 AM
Last Post: DeaD_EyE
  Iterating over pandas.df to check for values out of range Padowan 14 4,685 Nov-26-2017, 04:37 PM
Last Post: heiner55
  check conenction takes byte or not viens 1 808 Nov-01-2017, 06:45 PM
Last Post: nilamo
  "Call the subroutine in order to check..." misa_san 1 1,032 Sep-24-2017, 09:30 AM
Last Post: stranac
  How can I check out my localhost? Mike Ru 2 1,259 Aug-05-2017, 05:50 PM
Last Post: Mike Ru
  Finding Number of Lowercase letters in a Set Steven 6 1,864 May-26-2017, 03:11 PM
Last Post: Steven

Forum Jump:

Users browsing this thread: 1 Guest(s)