wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
var x int | var x int | Correct. | Go |
[x*x for x in arr if x > 90] | [x*x for x in arr if x > 90] | Correct list comprehension. | Python |
var x = 26; | var x = 26; | Correct. | Dart |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if data > 58
print('hello') | if data > 58:
print('hello') | Colon missing after if. | Python |
100a = 10 | a100 = 10 | Variable cannot start with digit. | Python |
for i=1,42 do print(i) end | for i=1,42 do print(i) end | Correct. | Lua |
const user:Person = {{name:'message'}}; | const user:Person = {{name:'message', age:47}}; | Add missing property. | TypeScript |
b > 48 & b < 68 | b > 48 and b < 68 | Use 'and' not '&'. | Python |
while result > 73
result -= 1 | while result > 73:
result -= 1 | Colon missing after while. | Python |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
[90, 31, 25 | [90, 31, 25] | Close bracket. | Ruby |
fn compute() -> i32 {{ 81 }} | fn compute() -> i32 {{ 81 }} | Correct. | Rust |
foo | foo() | Add parentheses. | Kotlin |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
function foo() {{
return
{{key:'result'}}
}} | function foo() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
if (index = 46) {{}} | if (index == 46) {{}} | Use ==. | Kotlin |
.Product {{ color: #fff; }} | .Product {{ color: #fff; }} | Correct. | CSS |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
jwt.sign({{id:93}}, 'key'); | jwt.sign({{id:93}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
arr[79] | if arr.indices.contains(79) {{ arr[79] }} | Check index. | Swift |
print 'hello' | print('hello') | print needs parentheses. | Python |
val c = 'data' | val c = "data" | Double quotes. | Kotlin |
y = test | y = 'test' | Quote strings. | Python |
let s = String::from("message"); let ref=&s; s.push_str("!"); | let mut s = String::from("message"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
let val: Int = 'info' | let val: String = 'info' | Fix type. | Swift |
def process():
print('hello') | def process():
print('hello') | Indent function body. | Python |
["hello", 51] | ["hello", 51] | Correct. | JSON |
list.forEach(function(item) {{ console.log(item); }}) | list.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
val num: Int = 'value' | val num: String = 'value' | Fix type. | Kotlin |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(30); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(30); | Correct. | Node.js |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if (a = 52) {} | if (a == 52) {} | Use ==. | Dart |
let foo = 48; let foo = 38; | let foo = 48; foo = 38; | Duplicate declaration. | JavaScript |
data(66) | if length(data) >= 66, data(66), end | Check length. | MATLAB |
{{"value":"value" "name":35}} | {{"value":"value", "name":35}} | Add comma. | JSON |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
let a = 27; a += 1; | let mut a = 27; a += 1; | Need mut to modify. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
for (int i=0; i<64; i++) {{}} | for (int i=0; i<64; i++) {{}} | Correct. | Java |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
String count = 'info'; | String count = "info"; | Double quotes. | Java |
function baz(): void {{ return 71; }} | function baz(): number {{ return 71; }} | Return type mismatch. | TypeScript |
{{'value':'info'}} | {{"value":"info"}} | Use double quotes. | JSON |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
object Product {{ def main(args: Array[String]) = println("output") }} | object Product {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(32); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(32, () => console.log('listening')); | Add callback. | Node.js |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
local val = 95 | local val = 95 | Correct. | Lua |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
{{'value':33, 'age' 4}} | {{'value':33, 'age':4}} | Colon missing. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if a = 74 {{}} | if a == 74 {{}} | Use ==. | Swift |
if a = 44 | if a == 44 | Use ==. | MATLAB |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
if (item = 43) {{}} | if (item === 43) {{}} | Use === for equality. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
h1 {{ font-size:16px color:#fff; }} | h1 {{ font-size:16px; color:#fff; }} | Add semicolon. | CSS |
class Person {{ int b; }}
obj.b=5; | class Person {{ public int b; }}
obj.b=5; | Make field public. | Java |
function render(item)
print(item)
end | function render(item)
print(item)
end | Correct. | Lua |
<person age=9> | <person age="9"> | Quote attribute. | XML |
if (num = 31) | if (num == 31) | Use ==. | R |
for result in range(97)
print(result) | for result in range(97):
print(result) | Colon after for. | Python |
my @arr = (3,9,55); | my @arr = (3,9,55); | Correct. | Perl |
x := 23 | x := 23 | Correct. | Go |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
if y = 48 | if y == 48 | Use ==. | Go |
yield a | yield a | Correct yield. | Python |
let item: number = 'message'; | let item: string = 'message'; | Fix type. | TypeScript |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
let x = 91; | let x = 91; | Correct. | JavaScript |
JOIN profiles ON users.id = profiles.age | JOIN profiles ON users.id = profiles.age | Correct. | SQL |
switch(z){{ case 10: break; }} | switch(z){{ case 10: break; default: break; }} | Add default case. | Java |
random.sqrt(27) | import random
random.sqrt(27) | Import module first. | Python |
arr[74] | if (arr.indices.contains(74)) arr[74] | Check index. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<br></br> | <br> | Self-closing. | HTML |
<p>test <b>data</p></b> | <p>test <b>data</b></p> | Nest properly. | HTML |
UPDATE items SET email='info' WHERE role=30 | UPDATE items SET email='info' WHERE role=30; | Add semicolon. | SQL |
if (c = 49) {{}} | if (c == 49) {{}} | Use ==. | Java |
WHERE status = '97' | WHERE status = 97 | Don't quote integer. | SQL |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.