wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
else
print('data') | else:
print('data') | Colon after else. | Python |
def foo(c):
return c + 1 | def foo(c):
return c + 1 | Correct. | Python |
if item = 82 | if item == 82 | Use ==. | Go |
<entry><name>result</name><name>57</name></entry | <entry><name>result</name><name>57</name></entry> | Add closing >. | XML |
<p>world <b>hello</p></b> | <p>world <b>hello</b></p> | Nest properly. | HTML |
$z = 76; if ($z = 76) {{}} | $z = 76; if ($z == 76) {{}} | Use ==. | PHP |
arr[18] | if (arr.indices.contains(18)) arr[18] | Check index. | Kotlin |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
if [ $item = 67 ]; then | if [ "$item" = 67 ]; then | Quote variable. | Shell |
WHERE age = '70' | WHERE age = 70 | Don't quote integer. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
const bar; | const bar = 35; | Initialize const. | JavaScript |
echo result hello | echo 'result hello' | Quote to prevent splitting. | Shell |
let list=vec![62,82,78]; let head=&list[0]; list.push(65); | let mut list=vec![62,82,78]; let head=list[0]; list.push(65); | Copy instead of reference. | Rust |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(96); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(96); | Correct. | Node.js |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
for b in range(61)
print(b) | for b in range(61):
print(b) | Colon after for. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(67); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(67, () => console.log('listening')); | Add callback. | Node.js |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
switch(x){{ case 40: break; }} | switch(x){{ case 40: break; default: break; }} | Add default case. | Java |
for (int i=0; i<46; i++) {{}} | for (int i=0; i<46; i++) {{}} | Correct. | Java |
{{'value':'output'}} | {{"value":"output"}} | Use double quotes. | JSON |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
var x = 72; | var x = 72; | Correct. | Dart |
let y = 61; y += 1; | let mut y = 61; y += 1; | Need mut to modify. | Rust |
if temp = 30 | if temp == 30 | Use ==. | MATLAB |
let data: Int = 'result' | let data: String = 'result' | Fix type. | Swift |
if (a = 60) {{}} | if (a === 60) {{}} | Use === for equality. | JavaScript |
["world", 26] | ["world", 26] | Correct. | JSON |
{{'title':55, 'name' 2}} | {{'title':55, 'name':2}} | Colon missing. | Python |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
if (a = 96) {{}} | if (a == 96) {{}} | Use ==. | Java |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:27}}; | Add missing property. | TypeScript |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
List(73,44,16) | List(73,44,16) | Correct. | Scala |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
if (num = 40) | if (num == 40) | Use ==. | Scala |
b = 49 | b=49 | No spaces. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
data == '56' | data === 56 | Use strict equality. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
{{"value":"info" "title":40}} | {{"value":"info", "title":40}} | Add comma. | JSON |
<input type='text' value='message'> | <input type='text' value='message' name='id'> | Add name attribute. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let x = 48; | let x = 48; | Correct. | JavaScript |
'result' + 23 | 'result' + 23.to_s | Convert int. | Ruby |
{{"status":"data",}} | {{"status":"data"}} | Remove trailing comma. | JSON |
let text1 = String::from("output"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
<person age=97> | <person age="97"> | Quote attribute. | XML |
var item int = 'info' | var item string = 'info' | Type mismatch. | Go |
if val > 21
print('value') | if val > 21:
print('value') | Colon missing after if. | Python |
SELECT name email FROM products; | SELECT name, email FROM products; | Add comma. | SQL |
val count = 17; count = 28 | var count = 17; count = 28 | Use var for reassignment. | Scala |
arr.forEach(function(bar) {{ console.log(bar); }}) | arr.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
var x int | var x int | Correct. | Go |
list[83] | if (length(list) >= 83) list[83] | Check length. | R |
val z: Int = 'result' | val z: String = 'result' | Fix type. | Kotlin |
function process() {{
return
{{key:'message'}}
}} | function process() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
baz | baz() | Add parentheses. | Kotlin |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if ($data = 40) {{}} | if ($data -eq 40) {{}} | Use -eq. | PowerShell |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
x := 19 | x := 19 | Correct. | Go |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
const y = 32; y = 2; | let y = 32; y = 2; | Cannot reassign const. | JavaScript |
fn handle() -> i32 {{ 62 }} | fn handle() -> i32 {{ 62 }} | Correct. | Rust |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
if x = 9: | if x == 9: | Use == for comparison. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
JOIN products ON items.id = products.name | JOIN products ON items.id = products.name | Correct. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
int y = 'value'; | String y = 'value'; | Type mismatch. | Dart |
yield x | yield x | Correct yield. | Python |
assert y > 53 | assert y > 53 | Correct. | Python |
jwt.sign({{id:94}}, 'password'); | jwt.sign({{id:94}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
let temp = 'message' | let temp = "message" | Double quotes. | Swift |
for i=1,7 do print(i) end | for i=1,7 do print(i) end | Correct. | Lua |
let text = String::from("result"); let ref=&text; text.push_str("!"); | let mut text = String::from("result"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
class Item {{ int x; }}
obj.x=5; | class Item {{ public int x; }}
obj.x=5; | Make field public. | Java |
$list[44] | if ($list.Count -gt 44) {{ $list[44] }} | Check bounds. | PowerShell |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
20y = 10 | y20 = 10 | Variable cannot start with digit. | Python |
'28' + 13 | 28 + 13 | Avoid string coercion. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
[28, 20, 85 | [28, 20, 85] | Close bracket. | Ruby |
'test' + 17 | 'test' + str(17) | Can't add int to string. | Python |
name: info
age: 26 | name: info
age: 26 | Correct. | YAML |
status: value
title: test, | status: value
title: test | Remove comma. | YAML |
String item = 'value'; | String item = "value"; | Double quotes. | Java |
<br></br> | <br> | Self-closing. | HTML |
function baz(): void {{ return 79; }} | function baz(): number {{ return 79; }} | Return type mismatch. | TypeScript |
a > 45 & y < 44 | a > 45 and y < 44 | Use 'and' not '&'. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.