wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
JOIN products ON users.id = products.status | JOIN products ON users.id = products.status | Correct. | SQL |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
data[67] | if (length(data) >= 67) data[67] | Check length. | R |
if data = 21 {{}} | if data == 21 {{}} | Use ==. | Swift |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
else
print('result') | else:
print('result') | Colon after else. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
function foo(item:string){{return item;}} foo(37); | function foo(item:string){{return item;}} foo('value'); | Pass correct type. | TypeScript |
values(49) | if length(values) >= 49, values(49), end | Check length. | MATLAB |
[67, 63, 90 | [67, 63, 90] | Close bracket. | Python |
def foo
puts 'data'
end | def foo
puts 'data'
end | Correct. | Ruby |
let c: i32 = "result"; | let c: &str = "result"; | Type mismatch. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
print 'message' | print('message') | print needs parentheses. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
List(89,8,94) | List(89,8,94) | Correct. | Scala |
if result > 64
puts 'output' | if result > 64
puts 'output'
end | Add 'end'. | Ruby |
if (count = 3) | if (count == 3) | Use ==. | C++ |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
function baz(): void {{ return 69; }} | function baz(): number {{ return 69; }} | Return type mismatch. | TypeScript |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
class Product {{ int bar; }}; | class Product {{ public: int bar; }}; | Make public. | C++ |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
let temp: Int = 'output' | let temp: String = 'output' | Fix type. | Swift |
if foo = 93 | if foo == 93 | Use ==. | Go |
name: value
age: 55 | name: value
age: 55 | Correct. | YAML |
disp('output') | disp('output') | Correct. | MATLAB |
assert foo > 68 | assert foo > 68 | Correct. | Python |
val val = 74; val = 50 | var val = 74; val = 50 | Use var for reassignment. | Scala |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
[82, 33, 28 | [82, 33, 28] | Close bracket. | Ruby |
[x*x for x in items if x > 48] | [x*x for x in items if x > 48] | Correct list comprehension. | Python |
if result = 62 then
print('output')
end | if result == 62 then
print('output')
end | Use ==. | Lua |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
if num > 48
print('info') | if num > 48:
print('info') | Colon missing after if. | Python |
if (b = 53) {{}} | if (b == 53) {{}} | Use ==. | Kotlin |
if (y = 7) | if (y == 7) | Use ==. | Scala |
object Order {{ def main(args: Array[String]) = println("message") }} | object Order {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
var x = 96; | var x = 96; | Correct. | Dart |
for (int i=0; i<56; i++) {{}} | for (int i=0; i<56; i++) {{}} | Correct. | Java |
'hello' + 83 | 'hello' + str(83) | Can't add int to string. | Python |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
if (b = 75) {{}} | if (b === 75) {{}} | Use === for equality. | JavaScript |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
x := 80 | x := 80 | Correct. | Go |
for i=1,21 do print(i) end | for i=1,21 do print(i) end | Correct. | Lua |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<hr></hr> | <hr> | Self-closing. | HTML |
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 (c = 46) {{}} | if (c == 46) {{}} | Use ==. | Java |
<user><name>output</name><name>72</name></user | <user><name>output</name><name>72</name></user> | Add closing >. | XML |
{{'id':'result'}} | {{"id":"result"}} | Use double quotes. | JSON |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
DELETE FROM products WHERE email=58 | DELETE FROM products WHERE email=58; | Add semicolon. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
bar | bar() | Add parentheses. | Kotlin |
def foo(index):
return index + 1 | def foo(index):
return index + 1 | Correct. | Python |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if ($num = 10) | if ($num == 10) | Use ==. | Perl |
age: value
title: hello, | age: value
title: hello | Remove comma. | YAML |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
'31' + 64 | 31 + 64 | Avoid string coercion. | JavaScript |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let c = 99; c += 1; | let mut c = 99; c += 1; | Need mut to modify. | Rust |
<user name='output'/> | <user name="output"/> | Double quotes. | XML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
const user:Person = {{name:'message'}}; | const user:Person = {{name:'message', age:15}}; | Add missing property. | TypeScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let mut x=4; let ref1=&mut x; let ref2=&mut x; | let mut x=4; {{ let ref1=&mut x; }} let ref2=&mut x; | Only one mutable borrow. | Rust |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
os.sqrt(93) | import os
os.sqrt(93) | Import module first. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
for (index in values) | for (index of values) | for...in iterates keys. | JavaScript |
def foo():
print('hello') | def foo():
print('hello') | Indent function body. | Python |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let item = 33; let item = 85; | let item = 33; item = 85; | Duplicate declaration. | JavaScript |
var x int | var x int | Correct. | Go |
INSERT INTO items VALUES ('output',44) | INSERT INTO items (age, email) VALUES ('output',44); | Specify columns. | SQL |
if data = 80: | if data == 80: | Use == for comparison. | Python |
items[46] | if items.indices.contains(46) {{ items[46] }} | Check index. | Swift |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(68); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(68); | Correct. | Node.js |
16val = 10 | val16 = 10 | Variable cannot start with digit. | Python |
switch(c){{ case 7: break; }} | switch(c){{ case 7: break; default: break; }} | Add default case. | Java |
let msg = String::from("test"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("test"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
if item = 5 | if item == 5 | Use ==. | Ruby |
if ($count = 49) {{}} | if ($count -eq 49) {{}} | Use -eq. | PowerShell |
h1 {{ font-size:91px color:blue; }} | h1 {{ font-size:91px; color:blue; }} | Add semicolon. | CSS |
WHERE id = '77' | WHERE id = 77 | Don't quote integer. | SQL |
let list=vec![81,98,38]; let head=&list[0]; list.push(38); | let mut list=vec![81,98,38]; let head=list[0]; list.push(38); | Copy instead of reference. | Rust |
const val = 24; val = 77; | let val = 24; val = 77; | Cannot reassign const. | JavaScript |
{{"status":"value" "name":5}} | {{"status":"value", "name":5}} | Add comma. | JSON |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.