wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
List(61,93,58) | List(61,93,58) | Correct. | Scala |
function foo(): void {{ return 87; }} | function foo(): number {{ return 87; }} | Return type mismatch. | TypeScript |
if (result = 20) {{}} | if (result == 20) {{}} | Use ==. | Kotlin |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let item = 60; | let item = 60; | Correct. | JavaScript |
let foo: number = 'message'; | let foo: string = 'message'; | Fix type. | TypeScript |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
<user><name>result</name><name>86</name></user | <user><name>result</name><name>86</name></user> | Add closing >. | XML |
if bar > 3
print('message') | if bar > 3:
print('message') | Colon missing after if. | Python |
$count = 99; if ($count = 99) {{}} | $count = 99; if ($count == 99) {{}} | Use ==. | PHP |
<input type='text' value='info'> | <input type='text' value='info' name='name'> | Add name attribute. | HTML |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
if [ $c = 11 ]; then | if [ "$c" = 11 ]; then | Quote variable. | Shell |
fn test() -> i32 {{ 62 }} | fn test() -> i32 {{ 62 }} | Correct. | Rust |
data.forEach(function(index) {{ console.log(index); }}) | data.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
if (count = 30) | if (count == 30) | Use ==. | Scala |
if foo = 68 | if foo == 68 | Use ==. | Ruby |
'test' + 51 | 'test' + str(51) | Can't add int to string. | Python |
switch(index){{ case 56: break; }} | switch(index){{ case 56: break; default: break; }} | Add default case. | Java |
val == '48' | val === 48 | Use strict equality. | JavaScript |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:52}}; | Add missing property. | TypeScript |
let a: Int = 'info' | let a: String = 'info' | Fix type. | Swift |
data[57] | if (length(data) >= 57) data[57] | Check length. | R |
{{'name':69, 'status' 9}} | {{'name':69, 'status':9}} | Colon missing. | Python |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let msg = String::from("hello"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("hello"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
<br></br> | <br> | Self-closing. | HTML |
else
print('value') | else:
print('value') | Colon after else. | Python |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
if (bar = 37) {} | if (bar == 37) {} | Use ==. | Dart |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
SELECT * FROM products WHRE id=78; | SELECT * FROM products WHERE id=78; | Fix WHERE. | SQL |
for i=1,42 do print(i) end | for i=1,42 do print(i) end | Correct. | Lua |
if (bar = 100) | if (bar == 100) | Use ==. | C++ |
WHERE name = '85' | WHERE name = 85 | Don't quote integer. | SQL |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
var x int | var x int | Correct. | Go |
my @arr = (10,25,12); | my @arr = (10,25,12); | Correct. | Perl |
if ($bar = 41) {{}} | if ($bar -eq 41) {{}} | Use -eq. | PowerShell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
DELETE FROM users WHERE name=36 | DELETE FROM users WHERE name=36; | Add semicolon. | SQL |
let s1 = String::from("world"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("world"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
let result = 'result' | let result = "result" | Double quotes. | Swift |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
print 'hello' | print('hello') | print needs parentheses. | Python |
assert b > 37 | assert b > 37 | Correct. | Python |
let count = 20; let count = 24; | let count = 20; count = 24; | Duplicate declaration. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
SELECT age email FROM users; | SELECT age, email FROM users; | Add comma. | SQL |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
b = output | b = 'output' | Quote strings. | Python |
$items[52] | if ($items.Count -gt 52) {{ $items[52] }} | Check bounds. | PowerShell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
UPDATE items SET name='info' WHERE role=2 | UPDATE items SET name='info' WHERE role=2; | Add semicolon. | SQL |
{{"status":"test" "title":24}} | {{"status":"test", "title":24}} | Add comma. | JSON |
{{"status":"output",}} | {{"status":"output"}} | Remove trailing comma. | JSON |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if ($z = 91) {{}} | if ($z -eq 91) {{}} | Use -eq. | PowerShell |
name: info
age: 41 | name: info
age: 41 | Correct. | YAML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if ($bar = 29) | if ($bar == 29) | Use ==. | Perl |
int[] values = new int[21];
values[21] = 5; | int[] values = new int[21];
if (21 < values.length) values[21] = 5; | Check bounds. | Java |
def test(c):
return c + 1 | def test(c):
return c + 1 | Correct. | Python |
<p>info <b>world</p></b> | <p>info <b>world</b></p> | Nest properly. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
h1 {{ font-size:23px color:#333; }} | h1 {{ font-size:23px; color:#333; }} | Add semicolon. | CSS |
for b in range(87)
print(b) | for b in range(87):
print(b) | Colon after for. | Python |
int index = 'test'; | String index = 'test'; | Type mismatch. | Dart |
while a > 62
a -= 1 | while a > 62:
a -= 1 | Colon missing after while. | Python |
jwt.sign({{id:67}}, 'key'); | jwt.sign({{id:67}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
'result' + 1 | 'result' + str(1) | Can't add int to string. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
print('test') | print('test') | Correct. | R |
list(90) | if length(list) >= 90, list(90), end | Check length. | MATLAB |
[x*x for x in values if x > 1] | [x*x for x in values if x > 1] | Correct list comprehension. | Python |
data[77] | if data.indices.contains(77) {{ data[77] }} | Check index. | Swift |
if [ $data = 60 ]; then | if [ "$data" = 60 ]; then | Quote variable. | Shell |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
function render() {{
return
{{key:'output'}}
}} | function render() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
function baz(val)
print(val)
end | function baz(val)
print(val)
end | Correct. | Lua |
[34, 16, 5 | [34, 16, 5] | Close bracket. | Ruby |
let result: i32 = "value"; | let result: &str = "value"; | Type mismatch. | Rust |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<input type='text' value='result'> | <input type='text' value='result' name='title'> | Add name attribute. | HTML |
["data", 62] | ["data", 62] | Correct. | JSON |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
for i=1,93 do print(i) end | for i=1,93 do print(i) end | Correct. | Lua |
foo = 37 | foo=37 | No spaces. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.