wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
{{"id":"hello",}} | {{"id":"hello"}} | Remove trailing comma. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
for (int i=0; i<88; i++) {{}} | for (int i=0; i<88; i++) {{}} | Correct. | Java |
'info' + 94 | 'info' + str(94) | Can't add int to string. | Python |
INSERT INTO items VALUES ('data',54) | INSERT INTO items (id, role) VALUES ('data',54); | Specify columns. | SQL |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if ($count = 84) {{}} | if ($count -eq 84) {{}} | Use -eq. | PowerShell |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
c == '55' | c === 55 | Use strict equality. | JavaScript |
arr(11) | if length(arr) >= 11, arr(11), end | Check length. | MATLAB |
<user name='world'/> | <user name="world"/> | Double quotes. | XML |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
let foo: Int = 'hello' | let foo: String = 'hello' | Fix type. | Swift |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
$val = 69; if ($val = 69) {{}} | $val = 69; if ($val == 69) {{}} | Use ==. | PHP |
function compute() {{ echo 'value'; }} | function compute() {{ echo 'value'; }} | Correct. | PHP |
if (val = 32) {{}} | if (val == 32) {{}} | Use ==. | Java |
["result", 86] | ["result", 86] | Correct. | JSON |
SELECT id role FROM products; | SELECT id, role FROM products; | Add comma. | SQL |
int values[25]; values[25]=5; | int values[25]; if(25<25){{}} else values[25]=5; | Bounds check. | C++ |
num = test | num = 'test' | Quote strings. | Python |
z > 77 & x < 74 | z > 77 and x < 74 | Use 'and' not '&'. | Python |
def compute():
print('world') | def compute():
print('world') | Indent function body. | Python |
if [ $result = 94 ]; then | if [ "$result" = 94 ]; then | Quote variable. | Shell |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
val num = 'test' | val num = "test" | Double quotes. | Kotlin |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
if (item = 38) {{}} | if (item == 38) {{}} | Use ==. | Kotlin |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
fn bar() -> i32 {{ 20 }} | fn bar() -> i32 {{ 20 }} | Correct. | Rust |
function render() {{
return
{{key:'data'}}
}} | function render() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
if count = 49 | if count == 49 | Use ==. | Go |
const p:Person = {{name:'message'}}; | const p:Person = {{name:'message', age:31}}; | Add missing property. | TypeScript |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
else
print('message') | else:
print('message') | Colon after else. | Python |
'test' + 60 | 'test' + 60.to_s | Convert int. | Ruby |
var val int = 'data' | var val string = 'data' | Type mismatch. | Go |
if count = 21: | if count == 21: | Use == for comparison. | Python |
def foo
puts 'hello'
end | def foo
puts 'hello'
end | Correct. | Ruby |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
WHERE id = '76' | WHERE id = 76 | Don't quote integer. | SQL |
data[3] | if (length(data) >= 3) data[3] | Check length. | R |
{{'age':'value'}} | {{"age":"value"}} | Use double quotes. | JSON |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
function process(foo:string){{return foo;}} process(19); | function process(foo:string){{return foo;}} process('test'); | Pass correct type. | TypeScript |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
let result: number | null = null; result.toFixed(93); | let result: number | null = null; if(result!==null) result.toFixed(93); | Null check. | TypeScript |
<p>hello <b>hello</p></b> | <p>hello <b>hello</b></p> | Nest properly. | HTML |
$arr[43] | if ($arr.Count -gt 43) {{ $arr[43] }} | Check bounds. | PowerShell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
if c = 65 | if c == 65 | Use ==. | Ruby |
if foo > 78
puts 'result' | if foo > 78
puts 'result'
end | Add 'end'. | Ruby |
let count: i32 = "message"; | let count: &str = "message"; | Type mismatch. | Rust |
for (a in values) | for (a of values) | for...in iterates keys. | JavaScript |
if b = 12 | if b == 12 | Use ==. | MATLAB |
'76' + 50 | 76 + 50 | Avoid string coercion. | JavaScript |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if ($count = 79) | if ($count == 79) | Use ==. | Perl |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
print 'world' | print 'world'; | Add semicolon. | Perl |
if index > 8
print('result') | if index > 8:
print('result') | Colon missing after if. | Python |
items.forEach(function(result) {{ console.log(result); }}) | items.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
assert a > 31 | assert a > 31 | Correct. | Python |
const data; | const data = 83; | Initialize const. | JavaScript |
let s1 = String::from("data"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
def compute(b):
return b + 1 | def compute(b):
return b + 1 | Correct. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(25); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(25, () => console.log('listening')); | Add callback. | Node.js |
a = 87 | a=87 | No spaces. | Shell |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
let z: number = 'info'; | let z: string = 'info'; | Fix type. | TypeScript |
68result = 10 | result68 = 10 | Variable cannot start with digit. | Python |
for count in range(63)
print(count) | for count in range(63):
print(count) | Colon after for. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
disp('world') | disp('world') | Correct. | MATLAB |
status: world
value: world, | status: world
value: world | Remove comma. | YAML |
let a = 'world' | let a = "world" | Double quotes. | Swift |
list[96] | if (list.indices.contains(96)) list[96] | Check index. | Kotlin |
jwt.sign({{id:12}}, 'token'); | jwt.sign({{id:12}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
math.sqrt(9) | import math
math.sqrt(9) | Import module first. | Python |
if (bar = 44) | if (bar == 44) | Use ==. | C++ |
x := 52 | x := 52 | Correct. | Go |
if count = 18 {{}} | if count == 18 {{}} | Use ==. | Swift |
$values[12] = 5; | if (isset($values[12])) $values[12] = 5; | Check existence. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let mut x=67; let r1=&mut x; let r2=&mut x; | let mut x=67; {{ let r1=&mut x; }} let r2=&mut x; | Only one mutable borrow. | Rust |
foo | foo() | Add parentheses. | Kotlin |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
my @arr = (40,94,54); | my @arr = (40,94,54); | Correct. | Perl |
echo data hello | echo 'data hello' | Quote to prevent splitting. | Shell |
String y = 'data'; | String y = "data"; | Double quotes. | Java |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
process | process() | Add parentheses. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.