Remember
istitle() checks title case across cased words: uppercase or titlecase starts followed by lowercase cased characters.
istitle() checks title case across cased words: uppercase or titlecase starts followed by lowercase cased characters.
Follow the example, change its sample, and compare what happens.
Explain the result and test your understanding.
Focus on how the names, objects, and calculations change. We’ll inspect the printed output in the next section.
Follow the code and watch its state change. Guided simulation.
text = 'Hello World'
result = text.istitle()
print(result)Top-level scope
'Hello World'Object 2 · boolTrueistitle() checks title case across cased words: uppercase or titlecase starts followed by lowercase cased characters.
(no output)
What do you expect this program to print?
EXAMPLE INSTRUCTIONS
text = 'Hello World'
result = text.istitle()
print(result)
|
v
DISPLAYED RESULT
True
FINAL BINDINGS
text --> object 1 (str)
result --> object 2 (bool)
object 1: 'Hello World'
object 2: TrueChoose a different sample input, then follow every step through to the output. Before revealing it, predict what the program will display.
Choose a sample and follow its execution. Guided simulation.
text = 'Hello World'
result = text.istitle()
print(result)Top-level scope
'Hello World'Object 2 · boolTrueThe example has finished. Compare the final output with the values and references above.
True
What do you expect this program to print?
text = 'Hello World'
result = text.istitle()
print(result)istitle() MethodThe istitle() method in Python checks whether each word in a string starts with an uppercase letter followed by lowercase letters. It returns True if the string is in title case.
string.istitle()
True – if all words are title-casedFalse – otherwisetext = "Hello World"
print(text.istitle())
True
text = "hello world"
print(text.istitle())
False
text = "Hello world"
print(text.istitle())
False
False.Words like "The USA" are not in title case (because "USA" is in all caps), so istitle() will return False.
Write a program that reads a line of text from the user and checks if it's in title case:
text = input("Enter a sentence: ")
if text.istitle():
print("The text is in title case.")
else:
print("The text is NOT in title case.")
string.istitle() checks if each word starts with a capital letter.True for title case, False otherwise.Connect what you noticed in the example with the idea below.
istitle() checks title case across cased words: uppercase or titlecase starts followed by lowercase cased characters.
istitle() only checks the first character of the entire string.
This is the misconception to avoid.Reference checks are optional and do not count toward course progress.