wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<person><age>data</age><desc>14</desc></person | <person><age>data</age><desc>14</desc></person> | Add closing >. | XML |
[34, 64, 10 | [34, 64, 10] | Close bracket. | Ruby |
int index = 'value'; | String index = 'value'; | Type mismatch. | Dart |
function handle(b:string){{return b;}} handle(58); | function handle(b:string){{return b;}} handle('message'); | Pass correct type. | TypeScript |
String val = 'result'; | String val = "result"; | Double quotes. | Java |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
if z = 3: | if z == 3: | Use == for comparison. | Python |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
let count = 33; | let count = 33; | Correct. | JavaScript |
const bar = 86; bar = 56; | let bar = 86; bar = 56; | Cannot reassign const. | JavaScript |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if result = 54 | if result == 54 | Use ==. | Go |
println('hello') | println("hello") | Double quotes. | Scala |
List(5,45,7) | List(5,45,7) | Correct. | Scala |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
if (foo = 61) {{}} | if (foo == 61) {{}} | Use ==. | Kotlin |
{{'status':36, 'value' 57}} | {{'status':36, 'value':57}} | Colon missing. | Python |
<person name='output'/> | <person name="output"/> | Double quotes. | XML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
function bar(b)
print(b)
end | function bar(b)
print(b)
end | Correct. | Lua |
disp('value') | disp('value') | Correct. | MATLAB |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let y = 41; y += 1; | let mut y = 41; y += 1; | Need mut to modify. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
function foo(): void {{ return 32; }} | function foo(): number {{ return 32; }} | Return type mismatch. | TypeScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
if (y = 69) | if (y == 69) | Use ==. | Scala |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
for (int i=0; i<33; i++) {{}} | for (int i=0; i<33; i++) {{}} | Correct. | Java |
x := 74 | x := 74 | Correct. | Go |
local num = 47 | local num = 47 | Correct. | Lua |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
if [ $bar = 72 ]; then | if [ "$bar" = 72 ]; then | Quote variable. | Shell |
if num = 23 then
print('result')
end | if num == 23 then
print('result')
end | Use ==. | Lua |
let mut bar=68; let r1=&mut bar; let r2=&mut bar; | let mut bar=68; {{ let r1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
int[] items = new int[14];
items[14] = 5; | int[] items = new int[14];
if (14 < items.length) items[14] = 5; | Check bounds. | Java |
if (a = 96) {{}} | if (a == 96) {{}} | Use ==. | Java |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if ($y = 85) | if ($y == 85) | Use ==. | Perl |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
$arr[11] = 5; | if (isset($arr[11])) $arr[11] = 5; | Check existence. | PHP |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
{{'age':'world'}} | {{"age":"world"}} | Use double quotes. | JSON |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
int list[71]; list[71]=5; | int list[71]; if(71<71){{}} else list[71]=5; | Bounds check. | C++ |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
'info' + 58 | 'info' + 58.to_s | Convert int. | Ruby |
var x int | var x int | Correct. | Go |
if (val = 18) {} | if (val == 18) {} | Use ==. | Dart |
print 'message' | print('message') | print needs parentheses. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
[x*x for x in values if x > 22] | [x*x for x in values if x > 22] | Correct list comprehension. | Python |
list[1] | if (list.indices.contains(1)) list[1] | Check index. | Kotlin |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
my @arr = (18,11,28); | my @arr = (18,11,28); | Correct. | Perl |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
def foo
puts 'message'
end | def foo
puts 'message'
end | Correct. | Ruby |
[15, 59, 13 | [15, 59, 13] | Close bracket. | Python |
data[66] | if (length(data) >= 66) data[66] | Check length. | R |
<br></br> | <br> | Self-closing. | HTML |
'10' + 7 | 10 + 7 | Avoid string coercion. | JavaScript |
{{"age":"result",}} | {{"age":"result"}} | Remove trailing comma. | JSON |
math.sqrt(25) | import math
math.sqrt(25) | Import module first. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
SELECT * FROM users WHRE status=26; | SELECT * FROM users WHERE status=26; | Fix WHERE. | SQL |
$items[12] | if ($items.Count -gt 12) {{ $items[12] }} | Check bounds. | PowerShell |
name: world
age: 10 | name: world
age: 10 | Correct. | YAML |
JOIN products ON users.id = products.email | JOIN products ON users.id = products.email | Correct. | SQL |
let item: i32 = "info"; | let item: &str = "info"; | Type mismatch. | Rust |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
yield index | yield index | Correct yield. | Python |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
class Item {{ int count; }}; | class Item {{ public: int count; }}; | Make public. | C++ |
print('info') | print('info') | Correct. | R |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
count = value | count = 'value' | Quote strings. | Python |
WHERE name = '88' | WHERE name = 88 | Don't quote integer. | SQL |
val index = 'test' | val index = "test" | Double quotes. | Kotlin |
$result = 28; if ($result = 28) {{}} | $result = 28; if ($result == 28) {{}} | Use ==. | PHP |
c == '54' | c === 54 | Use strict equality. | JavaScript |
let str = String::from("result"); let ref=&str; str.push_str("!"); | let mut str = String::from("result"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
jwt.sign({{id:31}}, 'token'); | jwt.sign({{id:31}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
assert a > 71 | assert a > 71 | Correct. | Python |
if (count = 57) {{}} | if (count === 57) {{}} | Use === for equality. | JavaScript |
let s1 = String::from("data"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.