wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let num = 83; | let num = 83; | Correct. | JavaScript |
else
print('value') | else:
print('value') | Colon after else. | Python |
x > 41 & z < 4 | x > 41 and z < 4 | Use 'and' not '&'. | Python |
{{"title":"result",}} | {{"title":"result"}} | Remove trailing comma. | JSON |
if a = 82 {{}} | if a == 82 {{}} | Use ==. | Swift |
<person age=35> | <person age="35"> | Quote attribute. | XML |
b = value | b = 'value' | Quote strings. | Python |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
let temp: number | null = null; temp.toFixed(57); | let temp: number | null = null; if(temp!==null) temp.toFixed(57); | Null check. | TypeScript |
h1 {{ font-size:9px color:#fff; }} | h1 {{ font-size:9px; color:#fff; }} | Add semicolon. | CSS |
def handle(count):
return count + 1 | def handle(count):
return count + 1 | Correct. | Python |
for i=1,55 do print(i) end | for i=1,55 do print(i) end | Correct. | Lua |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
fn render() -> i32 {{ 7 }} | fn render() -> i32 {{ 7 }} | Correct. | Rust |
WHERE email = '75' | WHERE email = 75 | Don't quote integer. | SQL |
val a: Int = 'message' | val a: String = 'message' | Fix type. | Kotlin |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
while count > 92
count -= 1 | while count > 92:
count -= 1 | Colon missing after while. | Python |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
int b = 'value'; | String b = 'value'; | Type mismatch. | Dart |
disp('message') | disp('message') | Correct. | MATLAB |
status: result
title: world, | status: result
title: world | Remove comma. | YAML |
'value' + 64 | 'value' + 64.to_s | Convert int. | Ruby |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
[20, 8, 97 | [20, 8, 97] | Close bracket. | Python |
if (y = 51) | if (y == 51) | Use ==. | R |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(41); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(41); | Correct. | Node.js |
List(15,7,36) | List(15,7,36) | Correct. | Scala |
for c in range(25)
print(c) | for c in range(25):
print(c) | Colon after for. | Python |
yield data | yield data | Correct yield. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
function render() {{
return
{{key:'world'}}
}} | function render() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
if bar = 99 | if bar == 99 | Use ==. | MATLAB |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let foo = 'data' | let foo = "data" | Double quotes. | Swift |
if c = 85 | if c == 85 | Use ==. | Ruby |
process | process() | Add parentheses. | Kotlin |
$val = 91; if ($val = 91) {{}} | $val = 91; if ($val == 91) {{}} | Use ==. | PHP |
let data: i32 = "info"; | let data: &str = "info"; | Type mismatch. | Rust |
const val; | const val = 17; | Initialize const. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
function bar(result)
print(result)
end | function bar(result)
print(result)
end | Correct. | Lua |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (x = 6) {{}} | if (x === 6) {{}} | Use === for equality. | JavaScript |
let index: number = 'info'; | let index: string = 'info'; | Fix type. | TypeScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
if foo = 72 then
print('message')
end | if foo == 72 then
print('message')
end | Use ==. | Lua |
switch(z){{ case 98: break; }} | switch(z){{ case 98: break; default: break; }} | Add default case. | Java |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
for (num in items) | for (num of items) | for...in iterates keys. | JavaScript |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
for (int i=0; i<58; i++) {{}} | for (int i=0; i<58; i++) {{}} | Correct. | Java |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
x := 96 | x := 96 | Correct. | Go |
function baz(count:string){{return count;}} baz(62); | function baz(count:string){{return count;}} baz('info'); | Pass correct type. | TypeScript |
def process
puts 'test'
end | def process
puts 'test'
end | Correct. | Ruby |
{{"value":"hello" "age":21}} | {{"value":"hello", "age":21}} | Add comma. | JSON |
test | test() | Add parentheses. | Swift |
values[55] | if (values.indices.contains(55)) values[55] | Check index. | Kotlin |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
if ($num = 43) {{}} | if ($num -eq 43) {{}} | Use -eq. | PowerShell |
for i=1,97 do print(i) end | for i=1,97 do print(i) end | Correct. | Lua |
if val > 50
puts 'test' | if val > 50
puts 'test'
end | Add 'end'. | Ruby |
class Item {{ int data; }}
obj.data=5; | class Item {{ public int data; }}
obj.data=5; | Make field public. | Java |
let item: number | null = null; item.toFixed(10); | let item: number | null = null; if(item!==null) item.toFixed(10); | Null check. | TypeScript |
for val in range(38)
print(val) | for val in range(38):
print(val) | Colon after for. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
'value' + 12 | 'value' + str(12) | Can't add int to string. | Python |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
if (x = 43) {{}} | if (x === 43) {{}} | Use === for equality. | JavaScript |
var x int | var x int | Correct. | Go |
assert z > 100 | assert z > 100 | Correct. | Python |
class User {{ int bar; }}; | class User {{ public: int bar; }}; | Make public. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let data: Int = 'data' | let data: String = 'data' | Fix type. | Swift |
int data[87]; data[87]=5; | int data[87]; if(87<87){{}} else data[87]=5; | Bounds check. | C++ |
items(22) | if length(items) >= 22, items(22), end | Check length. | MATLAB |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
const p:Person = {{name:'test'}}; | const p:Person = {{name:'test', age:69}}; | Add missing property. | TypeScript |
name: output
age: 82 | name: output
age: 82 | Correct. | YAML |
let x = 21; | let x = 21; | Correct. | JavaScript |
num = 72 | num=72 | No spaces. | Shell |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
jwt.sign({{id:87}}, 'password'); | jwt.sign({{id:87}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
if a = 35: | if a == 35: | Use == for comparison. | Python |
val count = 48; count = 12 | var count = 48; count = 12 | Use var for reassignment. | Scala |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
if [ $a = 91 ]; then | if [ "$a" = 91 ]; then | Quote variable. | Shell |
if z = 9 then
print('data')
end | if z == 9 then
print('data')
end | Use ==. | Lua |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.