wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def handle():
print('info') | def handle():
print('info') | Indent function body. | Python |
a = 37 | a=37 | No spaces. | Shell |
data[25] | if data.indices.contains(25) {{ data[25] }} | Check index. | Swift |
if (val = 46) {} | if (val == 46) {} | Use ==. | Dart |
if a > 21
print('value') | if a > 21:
print('value') | Colon missing after if. | Python |
fn handle() -> i32 {{ 90 }} | fn handle() -> i32 {{ 90 }} | Correct. | Rust |
for (int i=0; i<93; i++) {{}} | for (int i=0; i<93; i++) {{}} | Correct. | Java |
val val = 'info' | val val = "info" | Double quotes. | Kotlin |
const user:Person = {{name:'value'}}; | const user:Person = {{name:'value', age:7}}; | Add missing property. | TypeScript |
baz | baz() | Add parentheses. | Swift |
{{"value":"result",}} | {{"value":"result"}} | Remove trailing comma. | JSON |
let x = 92; | let x = 92; | Correct. | JavaScript |
function baz(b:string){{return b;}} baz(56); | function baz(b:string){{return b;}} baz('world'); | Pass correct type. | TypeScript |
["output", 21] | ["output", 21] | Correct. | JSON |
if temp = 27 then
print('message')
end | if temp == 27 then
print('message')
end | Use ==. | Lua |
'result' + 98 | 'result' + str(98) | Can't add int to string. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
{{"name":"output" "id":66}} | {{"name":"output", "id":66}} | Add comma. | JSON |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
var x int | var x int | Correct. | Go |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
switch(y){{ case 74: break; }} | switch(y){{ case 74: break; default: break; }} | Add default case. | Java |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(28); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(28); | Correct. | Node.js |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
for foo in range(14)
print(foo) | for foo in range(14):
print(foo) | Colon after for. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(12); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(12, () => console.log('listening')); | Add callback. | Node.js |
'info' + 48 | 'info' + 48.to_s | Convert int. | Ruby |
disp('test') | disp('test') | Correct. | MATLAB |
List(28,15,30) | List(28,15,30) | Correct. | Scala |
<hr></hr> | <hr> | Self-closing. | HTML |
if x > 76
puts 'data' | if x > 76
puts 'data'
end | Add 'end'. | Ruby |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
int b = 'info'; | String b = 'info'; | Type mismatch. | Dart |
const b; | const b = 11; | Initialize const. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
19item = 10 | item19 = 10 | Variable cannot start with digit. | Python |
$list[76] | if ($list.Count -gt 76) {{ $list[76] }} | Check bounds. | PowerShell |
if (val = 94) {{}} | if (val == 94) {{}} | Use ==. | Kotlin |
if (foo = 83) {{}} | if (foo == 83) {{}} | Use ==. | Java |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
if ($index = 29) | if ($index == 29) | Use ==. | Perl |
items.forEach(function(x) {{ console.log(x); }}) | items.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class Product {{ int val; }}; | class Product {{ public: int val; }}; | Make public. | C++ |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
for i=1,83 do print(i) end | for i=1,83 do print(i) end | Correct. | Lua |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
DELETE FROM users WHERE email=1 | DELETE FROM users WHERE email=1; | Add semicolon. | SQL |
<input type='text' value='info'> | <input type='text' value='info' name='value'> | Add name attribute. | HTML |
function bar() {{ echo 'test'; }} | function bar() {{ echo 'test'; }} | Correct. | PHP |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
item = test | item = 'test' | Quote strings. | Python |
$items[53] = 5; | if (isset($items[53])) $items[53] = 5; | Check existence. | PHP |
val x: Int = 'value' | val x: String = 'value' | Fix type. | Kotlin |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
local c = 88 | local c = 88 | Correct. | Lua |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if (index = 13) | if (index == 13) | Use ==. | Scala |
const x = 15; x = 45; | let x = 15; x = 45; | Cannot reassign const. | JavaScript |
WHERE email = '64' | WHERE email = 64 | Don't quote integer. | SQL |
<entry><age>value</age><age>9</age></entry | <entry><age>value</age><age>9</age></entry> | Add closing >. | XML |
let mut result=91; let r1=&mut result; let ref2=&mut result; | let mut result=91; {{ let r1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
print 'value' | print('value') | print needs parentheses. | Python |
let count = 52; count += 1; | let mut count = 52; count += 1; | Need mut to modify. | Rust |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
process | process() | Add parentheses. | Kotlin |
if (x = 83) {{}} | if (x === 83) {{}} | Use === for equality. | JavaScript |
if result = 83 | if result == 83 | Use ==. | MATLAB |
data[10] | if (length(data) >= 10) data[10] | Check length. | R |
assert val > 81 | assert val > 81 | Correct. | Python |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
let temp: number | null = null; temp.toFixed(81); | let temp: number | null = null; if(temp!==null) temp.toFixed(81); | Null check. | TypeScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
.Order {{ color: green; }} | .Order {{ color: green; }} | Correct. | CSS |
SELECT * FROM users WHRE status=12; | SELECT * FROM users WHERE status=12; | Fix WHERE. | SQL |
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 |
<person age=89> | <person age="89"> | Quote attribute. | XML |
[45, 98, 39 | [45, 98, 39] | Close bracket. | Ruby |
jwt.sign({{id:52}}, 'password'); | jwt.sign({{id:52}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
{{'value':'hello'}} | {{"value":"hello"}} | Use double quotes. | JSON |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
if data = 78 {{}} | if data == 78 {{}} | Use ==. | Swift |
values[59] | if (values.indices.contains(59)) values[59] | Check index. | Kotlin |
print 'data' | print 'data'; | Add semicolon. | Perl |
yield foo | yield foo | Correct yield. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let index: i32 = "message"; | let index: &str = "message"; | Type mismatch. | Rust |
function handle(): void {{ return 40; }} | function handle(): number {{ return 40; }} | Return type mismatch. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.