wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class Order {{ int c; }}
obj.c=5; | class Order {{ public int c; }}
obj.c=5; | Make field public. | Java |
let b: number | null = null; b.toFixed(49); | let b: number | null = null; if(b!==null) b.toFixed(49); | Null check. | TypeScript |
[x*x for x in list if x > 42] | [x*x for x in list if x > 42] | Correct list comprehension. | Python |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
if (val = 65) {{}} | if (val === 65) {{}} | Use === for equality. | JavaScript |
{{'age':10, 'title' 20}} | {{'age':10, 'title':20}} | Colon missing. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(92); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(92, () => console.log('listening')); | Add callback. | Node.js |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
#content {{ color: red; }} | #content {{ color: red; }} | Correct. | CSS |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
if foo = 7: | if foo == 7: | Use == for comparison. | Python |
object Item {{ def main(args: Array[String]) = println("hello") }} | object Item {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
function bar() {{
return
{{key:'output'}}
}} | function bar() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
$b = 41; if ($b = 41) {{}} | $b = 41; if ($b == 41) {{}} | Use ==. | PHP |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
values[66] | if (values.indices.contains(66)) values[66] | Check index. | Kotlin |
SELECT * FROM items WHRE age=82; | SELECT * FROM items WHERE age=82; | Fix WHERE. | SQL |
def compute():
print('info') | def compute():
print('info') | Indent function body. | Python |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
<entry><name>hello</name><name>26</name></entry | <entry><name>hello</name><name>26</name></entry> | Add closing >. | XML |
if a = 83 | if a == 83 | Use ==. | Go |
if y = 66 | if y == 66 | Use ==. | MATLAB |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
foo | foo() | Add parentheses. | Kotlin |
const p:Person = {{name:'output'}}; | const p:Person = {{name:'output', age:58}}; | Add missing property. | TypeScript |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
h1 {{ font-size:50px color:green; }} | h1 {{ font-size:50px; color:green; }} | Add semicolon. | CSS |
const foo = 83; foo = 74; | let foo = 83; foo = 74; | Cannot reassign const. | JavaScript |
let str1 = String::from("info"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
SELECT age role FROM orders; | SELECT age, role FROM orders; | Add comma. | SQL |
{{"status":"output" "age":37}} | {{"status":"output", "age":37}} | Add comma. | JSON |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
yield num | yield num | Correct yield. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
int arr[82]; arr[82]=5; | int arr[82]; if(82<82){{}} else arr[82]=5; | Bounds check. | C++ |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
name: data
age: 51 | name: data
age: 51 | Correct. | YAML |
local item = 53 | local item = 53 | Correct. | Lua |
print 'test' | print 'test'; | Add semicolon. | Perl |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
switch(z){{ case 98: break; }} | switch(z){{ case 98: break; default: break; }} | Add default case. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
disp('data') | disp('data') | Correct. | MATLAB |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function test(a)
print(a)
end | function test(a)
print(a)
end | Correct. | Lua |
<person age=53> | <person age="53"> | Quote attribute. | XML |
[35, 88, 42 | [35, 88, 42] | Close bracket. | Python |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
item = data | item = 'data' | Quote strings. | Python |
if z > 96
puts 'value' | if z > 96
puts 'value'
end | Add 'end'. | Ruby |
item == '76' | item === 76 | Use strict equality. | JavaScript |
for (int i=0; i<40; i++) {{}} | for (int i=0; i<40; i++) {{}} | Correct. | Java |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let num = 'test' | let num = "test" | Double quotes. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
UPDATE products SET status='output' WHERE email=22 | UPDATE products SET status='output' WHERE email=22; | Add semicolon. | SQL |
if (item = 69) | if (item == 69) | Use ==. | C++ |
if a = 9 {{}} | if a == 9 {{}} | Use ==. | Swift |
'info' + 59 | 'info' + str(59) | Can't add int to string. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
var x int | var x int | Correct. | Go |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
["info", 90] | ["info", 90] | Correct. | JSON |
let b = 40; b += 1; | let mut b = 40; b += 1; | Need mut to modify. | Rust |
values[2] | if (length(values) >= 2) values[2] | Check length. | R |
val b: Int = 'result' | val b: String = 'result' | Fix type. | Kotlin |
JOIN profiles ON users.id = profiles.id | JOIN profiles ON users.id = profiles.id | Correct. | SQL |
class Item {{ int c; }}; | class Item {{ public: int c; }}; | Make public. | C++ |
const foo; | const foo = 86; | Initialize const. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(100); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(100); | Correct. | Node.js |
int val = 'world'; | String val = 'world'; | Type mismatch. | Dart |
$data[90] | if ($data.Count -gt 90) {{ $data[90] }} | Check bounds. | PowerShell |
'test' + 47 | 'test' + 47.to_s | Convert int. | Ruby |
if (num = 58) {{}} | if (num == 58) {{}} | Use ==. | Kotlin |
40c = 10 | c40 = 10 | Variable cannot start with digit. | Python |
let mut data=8; let ref1=&mut data; let ref2=&mut data; | let mut data=8; {{ let ref1=&mut data; }} let ref2=&mut data; | Only one mutable borrow. | Rust |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let num: i32 = "data"; | let num: &str = "data"; | Type mismatch. | Rust |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
assert index > 1 | assert index > 1 | Correct. | Python |
'73' + 74 | 73 + 74 | Avoid string coercion. | JavaScript |
WHERE email = '42' | WHERE email = 42 | Don't quote integer. | SQL |
items.forEach(function(y) {{ console.log(y); }}) | items.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
INSERT INTO products VALUES ('value',73) | INSERT INTO products (name, status) VALUES ('value',73); | Specify columns. | SQL |
if num > 44
print('test') | if num > 44:
print('test') | Colon missing after if. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.