.upper()
Published Sep 6, 2023
Contribute to Docs
The .upper()
function converts a string to uppercase.
Syntax
string.upper(string)
The .upper()
function will convert all letters of a specified string to uppercase. Numbers and punctuation will remain unaffected.
Example
The example below shows how .upper()
takes a string with both upper and lower case letters and returns it in uppercase.
Note: The
.upper()
function creates a copy of the specified string to modify, leaving the original unchanged.
myString = "Bang!"print(myString)print(string.upper(myString))print(myString)
This code will display the following output:
Bang!BANG!Bang!
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Lua on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn Lua
Learn the basics of Lua, a general-purpose programming language used for building games, web apps, and developer tools.Beginner Friendly4 hours