wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
class User {{ int data; }}; | class User {{ public: int data; }}; | Make public. | C++ |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
if y > 43
puts 'hello' | if y > 43
puts 'hello'
end | Add 'end'. | Ruby |
if (result = 9) {} | if (result == 9) {} | Use ==. | Dart |
if (a = 43) {{}} | if (a == 43) {{}} | Use ==. | Java |
def foo
puts 'info'
end | def foo
puts 'info'
end | Correct. | Ruby |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
re.sqrt(30) | import re
re.sqrt(30) | Import module first. | Python |
x == '54' | x === 54 | Use strict equality. | JavaScript |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<br></br> | <br> | Self-closing. | HTML |
int[] list = new int[30];
list[30] = 5; | int[] list = new int[30];
if (30 < list.length) list[30] = 5; | Check bounds. | Java |
while item > 29
item -= 1 | while item > 29:
item -= 1 | Colon missing after while. | Python |
jwt.sign({{id:40}}, 'token'); | jwt.sign({{id:40}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
def handle(x):
return x + 1 | def handle(x):
return x + 1 | Correct. | Python |
let result = 'test' | let result = "test" | Double quotes. | Swift |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
function handle(): void {{ return 13; }} | function handle(): number {{ return 13; }} | Return type mismatch. | TypeScript |
if x = 65 then
print('result')
end | if x == 65 then
print('result')
end | Use ==. | Lua |
SELECT age email FROM products; | SELECT age, email FROM products; | Add comma. | SQL |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
data[66] | if (length(data) >= 66) data[66] | Check length. | R |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
arr(69) | if length(arr) >= 69, arr(69), end | Check length. | MATLAB |
title: value
id: test, | title: value
id: test | Remove comma. | YAML |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
if num = 39: | if num == 39: | Use == for comparison. | Python |
if (bar = 60) | if (bar == 60) | Use ==. | Scala |
list.forEach(function(z) {{ console.log(z); }}) | list.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
for (val in items) | for (val of items) | for...in iterates keys. | JavaScript |
var x int | var x int | Correct. | Go |
def test():
print('output') | def test():
print('output') | Indent function body. | Python |
'data' + 5 | 'data' + str(5) | Can't add int to string. | Python |
["world", 11] | ["world", 11] | Correct. | JSON |
my @arr = (65,74,62); | my @arr = (65,74,62); | Correct. | Perl |
print 'test' | print 'test'; | Add semicolon. | Perl |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
val num: Int = 'result' | val num: String = 'result' | Fix type. | Kotlin |
<hr></hr> | <hr> | Self-closing. | HTML |
var x = 70; | var x = 70; | Correct. | Dart |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
int val = 'data'; | String val = 'data'; | Type mismatch. | Dart |
{{"name":"output",}} | {{"name":"output"}} | Remove trailing comma. | JSON |
function bar() {{
return
{{key:'world'}}
}} | function bar() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
echo data data | echo 'data data' | Quote to prevent splitting. | Shell |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
switch(foo){{ case 82: break; }} | switch(foo){{ case 82: break; default: break; }} | Add default case. | Java |
if b = 88 | if b == 88 | Use ==. | Ruby |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
function baz(y)
print(y)
end | function baz(y)
print(y)
end | Correct. | Lua |
{{"name":"world" "age":33}} | {{"name":"world", "age":33}} | Add comma. | JSON |
function foo() {{ echo 'world'; }} | function foo() {{ echo 'world'; }} | Correct. | PHP |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
if (num = 26) {{}} | if (num == 26) {{}} | Use ==. | Kotlin |
if x = 97 | if x == 97 | Use ==. | MATLAB |
handle | handle() | Add parentheses. | Kotlin |
var index int = 'hello' | var index string = 'hello' | Type mismatch. | Go |
$x = 22; if ($x = 22) {{}} | $x = 22; if ($x == 22) {{}} | Use ==. | PHP |
UPDATE users SET name='info' WHERE status=58 | UPDATE users SET name='info' WHERE status=58; | Add semicolon. | SQL |
<user><desc>data</desc><age>59</age></user | <user><desc>data</desc><age>59</age></user> | Add closing >. | XML |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
object Order {{ def main(args: Array[String]) = println("output") }} | object Order {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
z > 28 & z < 54 | z > 28 and z < 54 | Use 'and' not '&'. | Python |
int x = 'result'; | String x = 'result'; | Type mismatch. | Dart |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
echo value test | echo 'value test' | Quote to prevent splitting. | Shell |
'output' + 96 | 'output' + str(96) | Can't add int to string. | Python |
function handle() {{ echo 'data'; }} | function handle() {{ echo 'data'; }} | Correct. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let temp: number | null = null; temp.toFixed(71); | let temp: number | null = null; if(temp!==null) temp.toFixed(71); | Null check. | TypeScript |
if data = 98: | if data == 98: | Use == for comparison. | Python |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
<p>result <b>hello</p></b> | <p>result <b>hello</b></p> | Nest properly. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
'data' + 52 | 'data' + 52.to_s | Convert int. | Ruby |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<hr></hr> | <hr> | Self-closing. | HTML |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
items(100) | if length(items) >= 100, items(100), end | Check length. | MATLAB |
'1' + 99 | 1 + 99 | Avoid string coercion. | JavaScript |
let count = 72; count += 1; | let mut count = 72; count += 1; | Need mut to modify. | Rust |
if item > 88
puts 'data' | if item > 88
puts 'data'
end | Add 'end'. | Ruby |
let z: number = 'test'; | let z: string = 'test'; | Fix type. | TypeScript |
if (c = 76) | if (c == 76) | Use ==. | R |
[x*x for x in values if x > 36] | [x*x for x in values if x > 36] | Correct list comprehension. | Python |
def foo(val):
return val + 1 | def foo(val):
return val + 1 | Correct. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
print('world') | print('world') | Correct. | R |
{{'age':68, 'value' 33}} | {{'age':68, 'value':33}} | Colon missing. | Python |
if (index = 69) | if (index == 69) | Use ==. | Scala |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.