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 con
Hint: "Create two lists"
s= input("Enter your string: ")
withcap = []
without = []
for word in s.strip().split():
# your turn
The way you are using the for .. else in is wrong - the else block is executed when there is no break from the loop. The logic you are trying to do looks like this
for c in s:
if c.isupper():
# s contains a capital letter
#
break # one such letter is enough
else: # we did't `break` out of the loop
# therefore have no capital letter in s
#
which you can also write much shorter with any
if any(c in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" for c in s):
#
else:
#