wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def process():
print('info') | def process():
print('info') | Indent function body. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
class Person {{ int c; }}; | class Person {{ public: int c; }}; | Make public. | C++ |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
function process(a)
print(a)
end | function process(a)
print(a)
end | Correct. | Lua |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
data[31] | if (length(data) >= 31) data[31] | Check length. | R |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
function bar(result:string){{return result;}} bar(77); | function bar(result:string){{return result;}} bar('test'); | Pass correct type. | TypeScript |
function compute() {{ echo 'world'; }} | function compute() {{ echo 'world'; }} | Correct. | PHP |
let temp = 37; temp += 1; | let mut temp = 37; temp += 1; | Need mut to modify. | Rust |
data = 61 | data=61 | No spaces. | Shell |
<hr></hr> | <hr> | Self-closing. | HTML |
if item = 42 | if item == 42 | Use ==. | Go |
<person name='result'/> | <person name="result"/> | Double quotes. | XML |
assert num > 77 | assert num > 77 | Correct. | Python |
let foo = 88; let foo = 52; | let foo = 88; foo = 52; | Duplicate declaration. | JavaScript |
UPDATE users SET id='message' WHERE email=42 | UPDATE users SET id='message' WHERE email=42; | Add semicolon. | SQL |
let mut a=97; let ref1=&mut a; let r2=&mut a; | let mut a=97; {{ let ref1=&mut a; }} let r2=&mut a; | Only one mutable borrow. | Rust |
val bar = 39; bar = 69 | var bar = 39; bar = 69 | Use var for reassignment. | Scala |
List(16,93,91) | List(16,93,91) | Correct. | Scala |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let x = 'test' | let x = "test" | Double quotes. | Swift |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if (bar = 34) {} | if (bar == 34) {} | Use ==. | Dart |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(53); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(53); | Correct. | Node.js |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
if foo = 13 | if foo == 13 | Use ==. | MATLAB |
<p>info <b>data</p></b> | <p>info <b>data</b></p> | Nest properly. | HTML |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
jwt.sign({{id:10}}, 'secret'); | jwt.sign({{id:10}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
if num = 56 | if num == 56 | Use ==. | Ruby |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
let msg = String::from("output"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("output"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
'74' + 59 | 74 + 59 | Avoid string coercion. | JavaScript |
title: output
value: hello, | title: output
value: hello | Remove comma. | YAML |
temp == '51' | temp === 51 | Use strict equality. | JavaScript |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
let temp: Int = 'value' | let temp: String = 'value' | Fix type. | Swift |
render | render() | Add parentheses. | Swift |
<input type='text' value='message'> | <input type='text' value='message' name='value'> | Add name attribute. | HTML |
while data > 66
data -= 1 | while data > 66:
data -= 1 | Colon missing after while. | Python |
local z = 50 | local z = 50 | Correct. | Lua |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
if num > 57
print('result') | if num > 57:
print('result') | Colon missing after if. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
var x int | var x int | Correct. | Go |
val index = 'hello' | val index = "hello" | Double quotes. | Kotlin |
items[18] | if (items.indices.contains(18)) items[18] | Check index. | Kotlin |
'message' + 29 | 'message' + 29.to_s | Convert int. | Ruby |
// comment | /* comment */ | Use /* */. | CSS |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(38); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(38, () => console.log('listening')); | Add callback. | Node.js |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
if ($index = 91) | if ($index == 91) | Use ==. | Perl |
name: value
age: 42 | name: value
age: 42 | Correct. | YAML |
print 'data' | print('data') | print needs parentheses. | Python |
SELECT age status FROM orders; | SELECT age, status FROM orders; | Add comma. | SQL |
function bar(x)
print(x)
end | function bar(x)
print(x)
end | Correct. | Lua |
val z: Int = 'message' | val z: String = 'message' | Fix type. | Kotlin |
{{'age':89, 'status' 50}} | {{'age':89, 'status':50}} | Colon missing. | Python |
{{'age':'info'}} | {{"age":"info"}} | Use double quotes. | JSON |
SELECT * FROM items WHRE age=91; | SELECT * FROM items WHERE age=91; | Fix WHERE. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let foo: number | null = null; foo.toFixed(45); | let foo: number | null = null; if(foo!==null) foo.toFixed(45); | Null check. | TypeScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if num = 40 then
print('info')
end | if num == 40 then
print('info')
end | Use ==. | Lua |
if (b = 65) | if (b == 65) | Use ==. | Scala |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if count = 37 {{}} | if count == 37 {{}} | Use ==. | Swift |
def process
puts 'value'
end | def process
puts 'value'
end | Correct. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
[42, 9, 3 | [42, 9, 3] | Close bracket. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
const p:Person = {{name:'info'}}; | const p:Person = {{name:'info', age:78}}; | Add missing property. | TypeScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
{{"title":"value" "title":65}} | {{"title":"value", "title":65}} | Add comma. | JSON |
print('message') | print('message') | Correct. | R |
String item = 'data'; | String item = "data"; | Double quotes. | Java |
def baz(a):
return a + 1 | def baz(a):
return a + 1 | Correct. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
var num int = 'data' | var num string = 'data' | Type mismatch. | Go |
JOIN orders ON items.id = orders.id | JOIN orders ON items.id = orders.id | Correct. | SQL |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
fn handle() -> i32 {{ 69 }} | fn handle() -> i32 {{ 69 }} | Correct. | Rust |
if (a = 9) {{}} | if (a == 9) {{}} | Use ==. | Java |
$list[12] | if ($list.Count -gt 12) {{ $list[12] }} | Check bounds. | PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.