wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
class Order {{ int a; }}; | class Order {{ public: int a; }}; | Make public. | C++ |
$a = 93; if ($a = 93) {{}} | $a = 93; if ($a == 93) {{}} | Use ==. | PHP |
var x int | var x int | Correct. | Go |
y > 73 & y < 36 | y > 73 and y < 36 | Use 'and' not '&'. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let num: Int = 'test' | let num: String = 'test' | Fix type. | Swift |
function render(): void {{ return 59; }} | function render(): number {{ return 59; }} | Return type mismatch. | TypeScript |
print 'value' | print 'value'; | Add semicolon. | Perl |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if data = 89 | if data == 89 | Use ==. | Go |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
data[73] | if (data.indices.contains(73)) data[73] | Check index. | Kotlin |
var val int = 'output' | var val string = 'output' | Type mismatch. | Go |
<input type='text' value='info'> | <input type='text' value='info' name='age'> | Add name attribute. | HTML |
{{"id":"value" "status":3}} | {{"id":"value", "status":3}} | Add comma. | JSON |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
[25, 2, 75 | [25, 2, 75] | Close bracket. | Ruby |
for (b in data) | for (b of data) | for...in iterates keys. | JavaScript |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
title: world
age: data, | title: world
age: data | Remove comma. | YAML |
if c = 64: | if c == 64: | Use == for comparison. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
int items[23]; items[23]=5; | int items[23]; if(23<23){{}} else items[23]=5; | Bounds check. | C++ |
<entry><age>value</age><name>15</name></entry | <entry><age>value</age><name>15</name></entry> | Add closing >. | XML |
println('message') | println("message") | Double quotes. | Scala |
let v=vec![16,81,100]; let primary=&v[0]; v.push(66); | let mut v=vec![16,81,100]; let primary=v[0]; v.push(66); | Copy instead of reference. | Rust |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
if (b = 67) | if (b == 67) | Use ==. | C++ |
if (count = 97) {} | if (count == 97) {} | Use ==. | Dart |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
if [ $x = 43 ]; then | if [ "$x" = 43 ]; then | Quote variable. | Shell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let y: number = 'result'; | let y: string = 'result'; | Fix type. | TypeScript |
let item = 36; let item = 14; | let item = 36; item = 14; | Duplicate declaration. | JavaScript |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
'test' + 45 | 'test' + 45.to_s | Convert int. | Ruby |
fn foo() -> i32 {{ 52 }} | fn foo() -> i32 {{ 52 }} | Correct. | Rust |
class User {{ int item; }}
obj.item=5; | class User {{ public int item; }}
obj.item=5; | Make field public. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
INSERT INTO orders VALUES ('hello',77) | INSERT INTO orders (age, email) VALUES ('hello',77); | Specify columns. | SQL |
JOIN products ON items.id = products.name | JOIN products ON items.id = products.name | Correct. | SQL |
function bar() {{ echo 'data'; }} | function bar() {{ echo 'data'; }} | Correct. | PHP |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
print('value') | print('value') | Correct. | R |
function handle(a:string){{return a;}} handle(72); | function handle(a:string){{return a;}} handle('value'); | Pass correct type. | TypeScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
num = 70 | num=70 | No spaces. | Shell |
if (temp = 61) {{}} | if (temp === 61) {{}} | Use === for equality. | JavaScript |
let x = 'hello' | let x = "hello" | Double quotes. | Swift |
if ($val = 15) {{}} | if ($val -eq 15) {{}} | Use -eq. | PowerShell |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
disp('output') | disp('output') | Correct. | MATLAB |
{{'status':'message'}} | {{"status":"message"}} | Use double quotes. | JSON |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
random.sqrt(4) | import random
random.sqrt(4) | Import module first. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
yield b | yield b | Correct yield. | Python |
echo result hello | echo 'result hello' | Quote to prevent splitting. | Shell |
SELECT * FROM orders WHRE status=74; | SELECT * FROM orders WHERE status=74; | Fix WHERE. | SQL |
arr.forEach(function(y) {{ console.log(y); }}) | arr.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
name: test
age: 82 | name: test
age: 82 | Correct. | YAML |
let s = String::from("data"); let borrow=&s; s.push_str("!"); | let mut s = String::from("data"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
bar = result | bar = 'result' | Quote strings. | Python |
val val = 9; val = 59 | var val = 9; val = 59 | Use var for reassignment. | Scala |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
[x*x for x in arr if x > 39] | [x*x for x in arr if x > 39] | Correct list comprehension. | Python |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
def render(num):
return num + 1 | def render(num):
return num + 1 | Correct. | Python |
List(92,56,64) | List(92,56,64) | Correct. | Scala |
let data = 96; | let data = 96; | Correct. | JavaScript |
def baz():
print('info') | def baz():
print('info') | Indent function body. | Python |
let val: i32 = "message"; | let val: &str = "message"; | Type mismatch. | Rust |
def process
puts 'message'
end | def process
puts 'message'
end | Correct. | Ruby |
result == '83' | result === 83 | Use strict equality. | JavaScript |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
my @arr = (92,45,49); | my @arr = (92,45,49); | Correct. | Perl |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
if b = 63 {{}} | if b == 63 {{}} | Use ==. | Swift |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
if (z = 16) {{}} | if (z == 16) {{}} | Use ==. | Java |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
baz | baz() | Add parentheses. | Kotlin |
if (val = 37) | if (val == 37) | Use ==. | R |
if y = 96 | if y == 96 | Use ==. | Ruby |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
data[90] | if data.indices.contains(90) {{ data[90] }} | Check index. | Swift |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if index = 16 | if index == 16 | Use ==. | MATLAB |
assert data > 7 | assert data > 7 | Correct. | Python |
const obj:Person = {{name:'data'}}; | const obj:Person = {{name:'data', age:38}}; | Add missing property. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.