wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const p:Person = {{name:'output'}}; | const p:Person = {{name:'output', age:23}}; | Add missing property. | TypeScript |
val result = 85; result = 23 | var result = 85; result = 23 | Use var for reassignment. | Scala |
if bar = 78 | if bar == 78 | Use ==. | MATLAB |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
<br></br> | <br> | Self-closing. | HTML |
$data[36] = 5; | if (isset($data[36])) $data[36] = 5; | Check existence. | PHP |
SELECT * FROM items WHRE id=1; | SELECT * FROM items WHERE id=1; | Fix WHERE. | SQL |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
def render():
print('world') | def render():
print('world') | Indent function body. | Python |
if (foo = 65) {{}} | if (foo === 65) {{}} | Use === for equality. | JavaScript |
for i=1,26 do print(i) end | for i=1,26 do print(i) end | Correct. | Lua |
function baz(bar:string){{return bar;}} baz(20); | function baz(bar:string){{return bar;}} baz('world'); | Pass correct type. | TypeScript |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
items(1) | if length(items) >= 1, items(1), end | Check length. | MATLAB |
for (count in arr) | for (count of arr) | for...in iterates keys. | JavaScript |
val a = 'message' | val a = "message" | Double quotes. | Kotlin |
<p>output <b>world</p></b> | <p>output <b>world</b></p> | Nest properly. | HTML |
for foo in range(41)
print(foo) | for foo in range(41):
print(foo) | Colon after for. | Python |
let str = String::from("value"); let ref=&str; str.push_str("!"); | let mut str = String::from("value"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
if data = 66 then
print('test')
end | if data == 66 then
print('test')
end | Use ==. | Lua |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
for (val in list) | for (val of list) | for...in iterates keys. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(28); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(28, () => console.log('listening')); | Add callback. | Node.js |
y = output | y = 'output' | Quote strings. | Python |
int list[98]; list[98]=5; | int list[98]; if(98<98){{}} else list[98]=5; | Bounds check. | C++ |
print 'data' | print('data') | print needs parentheses. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
SELECT * FROM items WHRE age=49; | SELECT * FROM items WHERE age=49; | Fix WHERE. | SQL |
String z = 'hello'; | String z = "hello"; | Double quotes. | Java |
print 'test' | print 'test'; | Add semicolon. | Perl |
println('result') | println("result") | Double quotes. | Scala |
if (a = 58) | if (a == 58) | Use ==. | R |
const x = 27; x = 31; | let x = 27; x = 31; | Cannot reassign const. | JavaScript |
{{'title':58, 'age' 90}} | {{'title':58, 'age':90}} | Colon missing. | Python |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
function baz(index:string){{return index;}} baz(32); | function baz(index:string){{return index;}} baz('world'); | Pass correct type. | TypeScript |
let data: number = 'result'; | let data: string = 'result'; | Fix type. | TypeScript |
<p>test <b>hello</p></b> | <p>test <b>hello</b></p> | Nest properly. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
{{"value":"output",}} | {{"value":"output"}} | Remove trailing comma. | JSON |
my @arr = (20,65,75); | my @arr = (20,65,75); | Correct. | Perl |
["result", 7] | ["result", 7] | Correct. | JSON |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
assert val > 44 | assert val > 44 | Correct. | Python |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
List(96,24,12) | List(96,24,12) | Correct. | Scala |
[38, 59, 79 | [38, 59, 79] | Close bracket. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
os.sqrt(27) | import os
os.sqrt(27) | Import module first. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
var x int = 'message' | var x string = 'message' | Type mismatch. | Go |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
disp('output') | disp('output') | Correct. | MATLAB |
<user name='info'/> | <user name="info"/> | Double quotes. | XML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<person age=32> | <person age="32"> | Quote attribute. | XML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
<hr></hr> | <hr> | Self-closing. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(77); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(77); | Correct. | Node.js |
let y = 91; | let y = 91; | Correct. | JavaScript |
const obj:Person = {{name:'test'}}; | const obj:Person = {{name:'test', age:87}}; | Add missing property. | TypeScript |
values[65] | if (length(values) >= 65) values[65] | Check length. | R |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
let index: i32 = "result"; | let index: &str = "result"; | Type mismatch. | Rust |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
DELETE FROM users WHERE age=4 | DELETE FROM users WHERE age=4; | Add semicolon. | SQL |
let mut val=62; let r1=&mut val; let r2=&mut val; | let mut val=62; {{ let r1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
local temp = 83 | local temp = 83 | Correct. | Lua |
<entry><age>test</age><name>72</name></entry | <entry><age>test</age><name>72</name></entry> | Add closing >. | XML |
for i=1,53 do print(i) end | for i=1,53 do print(i) end | Correct. | Lua |
data.forEach(function(foo) {{ console.log(foo); }}) | data.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if foo = 84 {{}} | if foo == 84 {{}} | Use ==. | Swift |
if z = 58: | if z == 58: | Use == for comparison. | Python |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
y > 8 & z < 86 | y > 8 and z < 86 | Use 'and' not '&'. | Python |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
let s1 = String::from("hello"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
if [ $x = 16 ]; then | if [ "$x" = 16 ]; then | Quote variable. | Shell |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
'test' + 25 | 'test' + 25.to_s | Convert int. | Ruby |
$y = 87; if ($y = 87) {{}} | $y = 87; if ($y == 87) {{}} | Use ==. | PHP |
JOIN profiles ON users.id = profiles.name | JOIN profiles ON users.id = profiles.name | Correct. | SQL |
31x = 10 | x31 = 10 | Variable cannot start with digit. | Python |
if val = 13 | if val == 13 | Use ==. | Ruby |
if a > 88
print('value') | if a > 88:
print('value') | Colon missing after if. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let val = 90; let val = 70; | let val = 90; val = 70; | Duplicate declaration. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.