Learn to Code via Tutorials on Repl.it!

← Back to all posts
A Crash Course in LOLCODE 🐱
minermaniac447 (287)

A Crash Course in LOLCODE

OHAI! This is a crash course in the beautiful programming language known as LOLCODE! LOLCODE is a great language, and while it is similar to many other programming languages, trying to learn it may confuse some people because of the syntax. For this tutorial, any time I say [variable1], [variable2], or [variable], as long as I'm not talking about initializing a variable, you can put a value instead.

Creating a new program

To begin a program, you need to have the line HAI 1.2. This will declare that it's a LOLCODE program that's written in LOLCODE 1.2. The last line in the program must be KTHXBYE.


There are two different ways of doing commenting - BTW and OBTW. The differences are shown below:

The indentation is not necessary, but it makes it easier to read.


Variables are dynamically typed in LOLCODE, so you don't have to give them a type when declared. To declare a variable, use I HAS A [variable]. However, if you do want to give it a type, you can use I HAS A [variable] ITZ A [type]. There are 4 usable types of variables:

  • TROOF (a boolean - WIN or FAIL, corresponding to true or false.)
  • NUMBR (an integer - whole numbers)
  • NUMBAR (a float - decimal places)
  • YARN (a string - text, defined by "")

Variable names are case-sensitive, so INT is different from Int. You can use capital and lowercase letters, underscores, and numbers - as long as neither underscores nor numbers begin the variable name. To assign one variable to another, use [variable 1] R [variable 2].


It's very simple to concatenate YARNS in LOLCODE - you use SMOOSH [variables to concatenate, seperated by AN] MKAY. It will cast any input given to it to a YARN before concatenating. See below for an example.


There are a couple different ways of casting a variable from 1 type to another. The first is MAEK [variable] A [type]. This will attempt to cast from whatever type the variable is to the desired type. However, this will not work if it's illogical - for instance, trying to cast letters into a NUMBR or NUMBAR. To cast a variable to a different type and save the output in a different variable, use [variable 1] R MAEK [variable 2] A [type].


There are 3 different types of expressions in LOLCODE - Math, Boolean, and Comparison. The basic form for all expressions is either [expression] [variable] or [expression] [variable1] AN [variable2].


In LOLCODE, you have all the typical expression types - addition, subtraction, multiplication, division, and modulus (remainder), as well as some less-common ones - min (returns the value of the smaller of 2 variables) and max (returns the value of the larger of 2 variables). If either variable is a YARN and has a decimal, it is cast to a NUMBAR for the calculation. If it doesn't have a decimal, it's cast to a NUMBR. If both variables used are NUMBRs, then integer math is performed. If one or both are NUMBARS, floating floating point math is invoked. See below for a list of math expressions:


The boolean expressions work pretty much as you would expect, comparing WINs and FAILs. You can use and, or, xor, and not. Any value passed to this is cast to a TROOF. See below for the complete list:


This is very similar to boolean expressions - it takes in 2 variables and checks if they're either the same or different. However, it doesn't have to be 2 TROOFS, but they do have to be the same type. "9" and 9 will NOT be recognized as the same. See below for examples


To output text, you have to use the VISIBLE [output] command. This can also be used with variables by using VISIBLE [variable]. See below for examples:


To get input from the user, you can use GIMMEH [variable]. For this, you MUST specify a variable because that is where the output is stored. GIMMEH stores input as a YARN, so if you want to get a NUMBR or NUMBAR you have to cast it as such.


Creating conditionals is fairly straightforward in LOLCODE. There are 2 basic formats - one utilizing TROOFs, and one utilizing other types of variables. To create a conditional using TROOFs, use the following:

To create a conditional using other variable types is a little more involved. Basically, OMG [value] is the same as checking if the expression is equal to [value], and OMGWTF is an else. To end a statement, you must put GTFO.


Loops are a somewhat confusing beast at first, but actually aren't that hard. First, you need IM IN YR [label for the loop - I would recommend just calling it LOOP]. Then, if you want to increase the iterator variable have UPPIN YR [variable], and if you want to decrease the iterator variable have NERFIN YR [variable]. Finally, if you want to go until a certain value, use TIL [expression], and if you want to go while a certain expression is true, use WILE [expression]. To end the loop, use IM OUTTA YR [label]. See below for an example:


Aaaand that's pretty much everything I could possibly find on the internet about LOLCODE... There is documentation for functions and BUKKITs (arrays), but I couldn't get them to work and so I decided against detailing them. If you still want MOAR LOLCODE documentation, go here, here, or here. If you want a fairly simple random python with turtle spiral generator, go check out my tutorial for that here. If you want a super long tutorial about how to make your own game using only python with turtle graphics, go here. If you liked this tutorial, feel free to leave an upvote. Thanks! :)

OwenBradstreet (133)

This is a great tutorial, covering most of the language.
LOLCODE can be hard to understand, I think you explained it quite well. You have my upvote!

minermaniac447 (287)

@OwenBradstreet Thanks! I'm glad you liked the tutorial! :D

brooc210 (6)

no lolcats were harmed in the making of this tutorial !

AquaMarine0421 (56)


lightningrock (155)

love it! is lolcode a joke? because the syntax is rly weird and funny too.

Reader8765 (19)

LOLCODE is a fun language. It was even featured in the newsletter once!

minermaniac447 (287)

@Reader8765 Yeah, that's why I did it for my tutorial. Glad you found it fun!

DabDatBass (14)

LOLCODE is easier to understand than JS, although LOLCODE is basically JS. Still fine and better to work with, lol

mkhoi (222)

(except those other horrible stuff...)

TimeDragon (5)

Self-taught in LOLCODE. Nice tutorial though!

niamh6 (0)

n u n u n u n u n u n u n n u n u n u n u n u n u n u n u n u n u n u

pbransby21920 (0)

i think you explained very well

fluffykitty421 (3)

i just wish replit could handle lolcode inputs better

FlaminHotValdez (750)


MemeManHimself (106)

for some reason this is so hard for me to learn and remember XD

King597 (3)





I don't know if I will ever actually use LOLCODE sometime in my life ever, but the syntax makes me laugh a lot lol. Thanks for the tutorial! :D

JSer (80)

Super cool! Now I don't have to browser that ugly TutorialsPoint website or watch crappy tutorial videos on YouTube to learn LOLCODE

AhmedKhalifaAhm (0)

DIFFRINT [variable 1] AN BIGGR OF [variable 1] AN [variable 2] BTW variable 1 > variable 2
DIFFRINT [variable 1] AN SMALLR OF [variable 1] AN [variable 2] BTW variable 1 < variable 2
I think it's the other way around:
(a != max(a, b) --> a < b)
(a != min(a, b) --> a > b)

jk85 (0)

you did a really good job on explaing lol code

aHen (0)

i adore this language

21Miya (171)

This language scares me, but for some reason I really want to try it now--In fact, this is my first time hearing about it. This is a great tutorial! Upvoted :)