wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def baz(result):
return result + 1 | def baz(result):
return result + 1 | Correct. | Python |
if ($a = 47) {{}} | if ($a -eq 47) {{}} | Use -eq. | PowerShell |
if z = 32 | if z == 32 | Use ==. | Ruby |
let data = 'result' | let data = "result" | Double quotes. | Swift |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
JOIN orders ON items.id = orders.id | JOIN orders ON items.id = orders.id | Correct. | SQL |
for (int i=0; i<27; i++) {{}} | for (int i=0; i<27; i++) {{}} | Correct. | Java |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
object Person {{ def main(args: Array[String]) = println("result") }} | object Person {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
INSERT INTO items VALUES ('message',59) | INSERT INTO items (age, email) VALUES ('message',59); | Specify columns. | SQL |
for i=1,34 do print(i) end | for i=1,34 do print(i) end | Correct. | Lua |
[x*x for x in items if x > 13] | [x*x for x in items if x > 13] | Correct list comprehension. | Python |
print 'world' | print 'world'; | Add semicolon. | Perl |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
<p>output <b>hello</p></b> | <p>output <b>hello</b></p> | Nest properly. | HTML |
class Order {{ int data; }}; | class Order {{ public: int data; }}; | Make public. | C++ |
for (item in list) | for (item of list) | for...in iterates keys. | JavaScript |
x := 98 | x := 98 | Correct. | Go |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
let item = 53; | let item = 53; | Correct. | JavaScript |
$result = 11; if ($result = 11) {{}} | $result = 11; if ($result == 11) {{}} | Use ==. | PHP |
<br></br> | <br> | Self-closing. | HTML |
let x: i32 = "info"; | let x: &str = "info"; | Type mismatch. | Rust |
if index = 19 | if index == 19 | Use ==. | Go |
if (val = 93) {{}} | if (val === 93) {{}} | Use === for equality. | JavaScript |
let x = 77; let x = 22; | let x = 77; x = 22; | Duplicate declaration. | JavaScript |
foo | foo() | Add parentheses. | Kotlin |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
let result = 'hello' | let result = "hello" | Double quotes. | Swift |
if ($index = 82) | if ($index == 82) | Use ==. | Perl |
[89, 54, 90 | [89, 54, 90] | Close bracket. | Ruby |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
if val = 91: | if val == 91: | Use == for comparison. | Python |
function foo(x:string){{return x;}} foo(8); | function foo(x:string){{return x;}} foo('world'); | Pass correct type. | TypeScript |
if data > 3
puts 'data' | if data > 3
puts 'data'
end | Add 'end'. | Ruby |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let bar = 61; | let bar = 61; | Correct. | JavaScript |
JOIN profiles ON items.id = profiles.status | JOIN profiles ON items.id = profiles.status | Correct. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(74); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(74, () => console.log('listening')); | Add callback. | Node.js |
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 |
{{"name":"world" "title":54}} | {{"name":"world", "title":54}} | Add comma. | JSON |
list[21] | if list.indices.contains(21) {{ list[21] }} | Check index. | Swift |
for i=1,39 do print(i) end | for i=1,39 do print(i) end | Correct. | Lua |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
var x int | var x int | Correct. | Go |
name: output
age: 23 | name: output
age: 23 | Correct. | YAML |
// comment | /* comment */ | Use /* */. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let y: Int = 'info' | let y: String = 'info' | Fix type. | Swift |
if (index = 17) {{}} | if (index == 17) {{}} | Use ==. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
x := 4 | x := 4 | Correct. | Go |
for b in range(96)
print(b) | for b in range(96):
print(b) | Colon after for. | Python |
List(27,31,51) | List(27,31,51) | Correct. | Scala |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
local z = 19 | local z = 19 | Correct. | Lua |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
const p:Person = {{name:'world'}}; | const p:Person = {{name:'world', age:52}}; | Add missing property. | TypeScript |
let a: number = 'hello'; | let a: string = 'hello'; | Fix type. | TypeScript |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
<person age=20> | <person age="20"> | Quote attribute. | XML |
let mut index=2; let ref1=&mut index; let r2=&mut index; | let mut index=2; {{ let ref1=&mut index; }} let r2=&mut index; | Only one mutable borrow. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
switch(data){{ case 68: break; }} | switch(data){{ case 68: break; default: break; }} | Add default case. | Java |
function test() {{ echo 'world'; }} | function test() {{ echo 'world'; }} | Correct. | PHP |
if (a = 55) | if (a == 55) | Use ==. | Scala |
result = test | result = 'test' | Quote strings. | Python |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
list.forEach(function(count) {{ console.log(count); }}) | list.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
print('output') | print('output') | Correct. | R |
values[19] | if (values.indices.contains(19)) values[19] | Check index. | Kotlin |
let vec=vec![96,58,46]; let first=&vec[0]; vec.push(26); | let mut vec=vec![96,58,46]; let first=vec[0]; vec.push(26); | Copy instead of reference. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if result = 52 | if result == 52 | Use ==. | MATLAB |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if data = 52 | if data == 52 | Use ==. | Ruby |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
String bar = 'hello'; | String bar = "hello"; | Double quotes. | Java |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
h1 {{ font-size:100px color:#333; }} | h1 {{ font-size:100px; color:#333; }} | Add semicolon. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
def bar():
print('world') | def bar():
print('world') | Indent function body. | Python |
fn test() -> i32 {{ 21 }} | fn test() -> i32 {{ 21 }} | Correct. | Rust |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
int[] data = new int[35];
data[35] = 5; | int[] data = new int[35];
if (35 < data.length) data[35] = 5; | Check bounds. | Java |
if x = 10 then
print('output')
end | if x == 10 then
print('output')
end | Use ==. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.