wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
$arr[33] = 5; | if (isset($arr[33])) $arr[33] = 5; | Check existence. | PHP |
compute | compute() | Add parentheses. | Kotlin |
if ($result = 29) | if ($result == 29) | Use ==. | Perl |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
function process(x)
print(x)
end | function process(x)
print(x)
end | Correct. | Lua |
arr[67] | if (length(arr) >= 67) arr[67] | Check length. | R |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
let x = 26; x += 1; | let mut x = 26; x += 1; | Need mut to modify. | Rust |
let temp: number | null = null; temp.toFixed(90); | let temp: number | null = null; if(temp!==null) temp.toFixed(90); | Null check. | TypeScript |
["message", 25] | ["message", 25] | Correct. | JSON |
val x: Int = 'output' | val x: String = 'output' | Fix type. | Kotlin |
switch(data){{ case 18: break; }} | switch(data){{ case 18: break; default: break; }} | Add default case. | Java |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
compute | compute() | Add parentheses. | Swift |
if (x = 21) {{}} | if (x == 21) {{}} | Use ==. | Java |
.User {{ color: blue; }} | .User {{ color: blue; }} | Correct. | CSS |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
list(74) | if length(list) >= 74, list(74), end | Check length. | MATLAB |
[25, 66, 96 | [25, 66, 96] | Close bracket. | Python |
val x = 'output' | val x = "output" | Double quotes. | Kotlin |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
List(86,92,36) | List(86,92,36) | Correct. | Scala |
$val = 36; if ($val = 36) {{}} | $val = 36; if ($val == 36) {{}} | Use ==. | PHP |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
re.sqrt(23) | import re
re.sqrt(23) | Import module first. | Python |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
if (bar = 45) {{}} | if (bar === 45) {{}} | Use === for equality. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
print('world') | print('world') | Correct. | R |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
{{'value':33, 'status' 33}} | {{'value':33, 'status':33}} | Colon missing. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if (bar = 47) | if (bar == 47) | Use ==. | Scala |
SELECT * FROM orders WHRE age=10; | SELECT * FROM orders WHERE age=10; | Fix WHERE. | SQL |
for temp in range(89)
print(temp) | for temp in range(89):
print(temp) | Colon after for. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
a == '59' | a === 59 | Use strict equality. | JavaScript |
if (index = 65) {{}} | if (index == 65) {{}} | Use ==. | Kotlin |
'27' + 49 | 27 + 49 | Avoid string coercion. | JavaScript |
yield y | yield y | Correct yield. | Python |
data[73] | if (data.indices.contains(73)) data[73] | Check index. | Kotlin |
def render():
print('result') | def render():
print('result') | Indent function body. | Python |
INSERT INTO users VALUES ('world',98) | INSERT INTO users (id, email) VALUES ('world',98); | Specify columns. | SQL |
if (b = 78) | if (b == 78) | Use ==. | R |
disp('world') | disp('world') | Correct. | MATLAB |
for i=1,55 do print(i) end | for i=1,55 do print(i) end | Correct. | Lua |
if [ $index = 80 ]; then | if [ "$index" = 80 ]; then | Quote variable. | Shell |
'world' + 56 | 'world' + 56.to_s | Convert int. | Ruby |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let z: Int = 'world' | let z: String = 'world' | Fix type. | Swift |
function process() {{
return
{{key:'test'}}
}} | function process() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
{{"name":"world",}} | {{"name":"world"}} | Remove trailing comma. | JSON |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
print 'world' | print 'world'; | Add semicolon. | Perl |
const bar; | const bar = 77; | Initialize const. | JavaScript |
9temp = 10 | temp9 = 10 | Variable cannot start with digit. | Python |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
class Item {{ int item; }}; | class Item {{ public: int item; }}; | Make public. | C++ |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let a: i32 = "hello"; | let a: &str = "hello"; | Type mismatch. | Rust |
echo output hello | echo 'output hello' | Quote to prevent splitting. | Shell |
while result > 84
result -= 1 | while result > 84:
result -= 1 | Colon missing after while. | Python |
<entry><age>data</age><name>58</name></entry | <entry><age>data</age><name>58</name></entry> | Add closing >. | XML |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
let data = 'world' | let data = "world" | Double quotes. | Swift |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
int[] data = new int[10];
data[10] = 5; | int[] data = new int[10];
if (10 < data.length) data[10] = 5; | Check bounds. | Java |
for (int i=0; i<54; i++) {{}} | for (int i=0; i<54; i++) {{}} | Correct. | Java |
name: value
age: 53 | name: value
age: 53 | Correct. | YAML |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
b = 34 | b=34 | No spaces. | Shell |
var bar int = 'test' | var bar string = 'test' | Type mismatch. | Go |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
const num = 44; num = 1; | let num = 44; num = 1; | Cannot reassign const. | JavaScript |
{{"value":"output" "value":62}} | {{"value":"output", "value":62}} | Add comma. | JSON |
println('result') | println("result") | Double quotes. | Scala |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
def process(x):
return x + 1 | def process(x):
return x + 1 | Correct. | Python |
val c = 13; c = 2 | var c = 13; c = 2 | Use var for reassignment. | Scala |
x := 41 | x := 41 | Correct. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
result = data | result = 'data' | Quote strings. | Python |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
print 'value' | print('value') | print needs parentheses. | Python |
const p:Person = {{name:'hello'}}; | const p:Person = {{name:'hello', age:29}}; | Add missing property. | TypeScript |
if count = 36 then
print('output')
end | if count == 36 then
print('output')
end | Use ==. | Lua |
class Product {{ int result; }}
obj.result=5; | class Product {{ public int result; }}
obj.result=5; | Make field public. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.