Reference · Strings
upper
signature
upper(str) -> strWhat it does
The text in upper case. It knows all of Unicode, so letters outside ASCII are
converted too, and a letter that grows when capitalised does: "ß" becomes "SS".
Digits, punctuation and whitespace stay as they are.
Examples
print(upper("hello"))print(upper("straße"))print(upper("Ærøskøbing 42, ok?"))output
HELLOSTRASSEÆRØSKØBING 42, OK?Edge cases
- The empty string gives the empty string.
- The result can be longer than the text:
"ß"is one character,"SS"two. - Case is not folded for comparing:
upper(a) == upper(b)is a fine equality test for ASCII, but for text in any language compare withloweras well, since some letters only round-trip one way.
print(upper(""), len(upper("ß")))print(upper("fi") == "FI")output
2trueErrors
An argument that is not a string is a runtime error, not an error value: upper(42)
stops the request. Convert first with str.
this one fails
print(upper(42))output
line 1: `upper` expects a str as argument 1, got intChaining
In a pipeline the text comes first, so upper takes it as its only argument:
print(" mixed Case " | trim | upper)print(["ann", "bob"] | map(upper))output
MIXED CASE["ANN", "BOB"]See also
Thread
Thread 0 posts
On upper(): questions, tips, corrections, and code that uses it.
No posts yet. The first one opens the thread.
Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo