My homework assignment is to Write a program that reads a string from the user and creates a list of words from the input.Create two lists, one containing the words that contain at least one upper-case letter and one of the words that don't contain any upper-case letters. Use a single for loop to print out the words with upper-case letters in them, followed by the words with no upper-case letters in them, one word per line.
What I know is not correct:
s= input("Enter your string: ")
words = sorted(s.strip().split())
for word in words:
print (word)
Because it only sorts the sequence if the Capitol is in the first character. For this assignment a character could appear any where within a word. Such as, 'tHis is a sTring'.
I was playing around with a solution that looked similar to this, just to see if I could get the words with CAPS out..But it just wasnt working:
s = input("Please enter a sentence: ")
while True:
cap = 0
s = s.strip().split()
for c in s:
if c in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
print(c[:cap])
cap += 1
else:
print("not the answer")
break
But a regular expression would probably do a better job than writing out the whole alphabet.
Any help is much appreciated. Needless to say I am new to python.