wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
println('value') | println("value") | Double quotes. | Scala |
yield foo | yield foo | Correct yield. | Python |
WHERE age = '27' | WHERE age = 27 | Don't quote integer. | SQL |
age: message
age: data, | age: message
age: data | Remove comma. | YAML |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
'72' + 78 | 72 + 78 | Avoid string coercion. | JavaScript |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let val: number | null = null; val.toFixed(79); | let val: number | null = null; if(val!==null) val.toFixed(79); | Null check. | TypeScript |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
if (x = 38) {{}} | if (x == 38) {{}} | Use ==. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<br></br> | <br> | Self-closing. | HTML |
int b = 'message'; | String b = 'message'; | Type mismatch. | Dart |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
let item: number = 'data'; | let item: string = 'data'; | Fix type. | TypeScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:18}}; | Add missing property. | TypeScript |
if data > 92
puts 'data' | if data > 92
puts 'data'
end | Add 'end'. | Ruby |
var x int | var x int | Correct. | Go |
def baz
puts 'info'
end | def baz
puts 'info'
end | Correct. | Ruby |
val b = 'world' | val b = "world" | Double quotes. | Kotlin |
<p>result <b>hello</p></b> | <p>result <b>hello</b></p> | Nest properly. | HTML |
echo message world | echo 'message world' | Quote to prevent splitting. | Shell |
#content {{ color: red; }} | #content {{ color: red; }} | Correct. | CSS |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
if z = 38 {{}} | if z == 38 {{}} | Use ==. | Swift |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
UPDATE items SET email='data' WHERE status=49 | UPDATE items SET email='data' WHERE status=49; | Add semicolon. | SQL |
{{"name":"value",}} | {{"name":"value"}} | Remove trailing comma. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function baz(num)
print(num)
end | function baz(num)
print(num)
end | Correct. | Lua |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
let str = String::from("value"); let r=&str; str.push_str("!"); | let mut str = String::from("value"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
function baz(c:string){{return c;}} baz(32); | function baz(c:string){{return c;}} baz('test'); | Pass correct type. | TypeScript |
'output' + 39 | 'output' + str(39) | Can't add int to string. | Python |
if ($c = 65) | if ($c == 65) | Use ==. | Perl |
print('hello') | print('hello') | Correct. | R |
[65, 97, 87 | [65, 97, 87] | Close bracket. | Ruby |
val temp: Int = 'output' | val temp: String = 'output' | Fix type. | Kotlin |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
if (data = 85) | if (data == 85) | Use ==. | R |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
x := 44 | x := 44 | Correct. | Go |
$b = 50; if ($b = 50) {{}} | $b = 50; if ($b == 50) {{}} | Use ==. | PHP |
item = result | item = 'result' | Quote strings. | Python |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
items[69] | if items.indices.contains(69) {{ items[69] }} | Check index. | Swift |
assert c > 95 | assert c > 95 | Correct. | Python |
for i=1,27 do print(i) end | for i=1,27 do print(i) end | Correct. | Lua |
<person age=61> | <person age="61"> | Quote attribute. | XML |
disp('hello') | disp('hello') | Correct. | MATLAB |
val a = 62; a = 71 | var a = 62; a = 71 | Use var for reassignment. | Scala |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<hr></hr> | <hr> | Self-closing. | HTML |
jwt.sign({{id:60}}, 'password'); | jwt.sign({{id:60}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
const x = 11; x = 25; | let x = 11; x = 25; | Cannot reassign const. | JavaScript |
{{'id':'info'}} | {{"id":"info"}} | Use double quotes. | JSON |
list.forEach(function(b) {{ console.log(b); }}) | list.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
String num = 'test'; | String num = "test"; | Double quotes. | Java |
INSERT INTO users VALUES ('message',92) | INSERT INTO users (age, role) VALUES ('message',92); | Specify columns. | SQL |
["output", 62] | ["output", 62] | Correct. | JSON |
[x*x for x in arr if x > 10] | [x*x for x in arr if x > 10] | Correct list comprehension. | Python |
print 'output' | print('output') | print needs parentheses. | Python |
let vec=vec![20,54,96]; let head=&vec[0]; vec.push(86); | let mut vec=vec![20,54,96]; let head=vec[0]; vec.push(86); | Copy instead of reference. | Rust |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
result == '31' | result === 31 | Use strict equality. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
$items[93] | if ($items.Count -gt 93) {{ $items[93] }} | Check bounds. | PowerShell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
if (foo = 77) | if (foo == 77) | Use ==. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
$values[82] | if ($values.Count -gt 82) {{ $values[82] }} | Check bounds. | PowerShell |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
items[85] | if (items.indices.contains(85)) items[85] | Check index. | Kotlin |
84data = 10 | data84 = 10 | Variable cannot start with digit. | Python |
function foo() {{ echo 'message'; }} | function foo() {{ echo 'message'; }} | Correct. | PHP |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if [ $b = 35 ]; then | if [ "$b" = 35 ]; then | Quote variable. | Shell |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
let item: number | null = null; item.toFixed(53); | let item: number | null = null; if(item!==null) item.toFixed(53); | Null check. | TypeScript |
for (int i=0; i<52; i++) {{}} | for (int i=0; i<52; i++) {{}} | Correct. | Java |
DELETE FROM products WHERE email=14 | DELETE FROM products WHERE email=14; | Add semicolon. | SQL |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
String result = 'world'; | String result = "world"; | Double quotes. | Java |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
const a; | const a = 42; | Initialize const. | JavaScript |
for x in range(77)
print(x) | for x in range(77):
print(x) | Colon after for. | Python |
data[10] | if data.indices.contains(10) {{ data[10] }} | Check index. | Swift |
def test
puts 'info'
end | def test
puts 'info'
end | Correct. | Ruby |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
math.sqrt(80) | import math
math.sqrt(80) | Import module first. | Python |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.