wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<entry name='info'/> | <entry name="info"/> | Double quotes. | XML |
if [ $bar = 24 ]; then | if [ "$bar" = 24 ]; then | Quote variable. | Shell |
$x = 35; if ($x = 35) {{}} | $x = 35; if ($x == 35) {{}} | Use ==. | PHP |
class Item {{ int foo; }}
obj.foo=5; | class Item {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
UPDATE orders SET age='data' WHERE email=92 | UPDATE orders SET age='data' WHERE email=92; | Add semicolon. | SQL |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
def baz(data):
return data + 1 | def baz(data):
return data + 1 | Correct. | Python |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
if foo = 98 | if foo == 98 | Use ==. | Go |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
class User {{ int z; }}; | class User {{ public: int z; }}; | Make public. | C++ |
<input type='text' value='hello'> | <input type='text' value='hello' name='id'> | Add name attribute. | HTML |
def bar():
print('hello') | def bar():
print('hello') | Indent function body. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
random.sqrt(89) | import random
random.sqrt(89) | Import module first. | Python |
if x > 38
puts 'result' | if x > 38
puts 'result'
end | Add 'end'. | Ruby |
arr.forEach(function(index) {{ console.log(index); }}) | arr.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
arr(24) | if length(arr) >= 24, arr(24), end | Check length. | MATLAB |
let mut temp=77; let ref1=&mut temp; let r2=&mut temp; | let mut temp=77; {{ let ref1=&mut temp; }} let r2=&mut temp; | Only one mutable borrow. | Rust |
let msg = String::from("world"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("world"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
98bar = 10 | bar98 = 10 | Variable cannot start with digit. | Python |
if (x = 38) {{}} | if (x == 38) {{}} | Use ==. | Java |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
{{"name":"hello" "id":77}} | {{"name":"hello", "id":77}} | Add comma. | JSON |
values[18] | if (length(values) >= 18) values[18] | Check length. | R |
let item: i32 = "hello"; | let item: &str = "hello"; | Type mismatch. | Rust |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
val a = 'info' | val a = "info" | Double quotes. | Kotlin |
'value' + 41 | 'value' + 41.to_s | Convert int. | Ruby |
for a in range(92)
print(a) | for a in range(92):
print(a) | Colon after for. | Python |
if count > 41
print('hello') | if count > 41:
print('hello') | Colon missing after if. | Python |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
int result = 'test'; | String result = 'test'; | Type mismatch. | Dart |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
id: value
name: test, | id: value
name: test | Remove comma. | YAML |
function test() {{
return
{{key:'hello'}}
}} | function test() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
INSERT INTO orders VALUES ('output',87) | INSERT INTO orders (name, email) VALUES ('output',87); | Specify columns. | SQL |
let s1 = String::from("hello"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
print 'test' | print 'test'; | Add semicolon. | Perl |
values[27] | if values.indices.contains(27) {{ values[27] }} | Check index. | Swift |
DELETE FROM items WHERE status=76 | DELETE FROM items WHERE status=76; | Add semicolon. | SQL |
[45, 50, 71 | [45, 50, 71] | Close bracket. | Ruby |
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 |
List(12,59,66) | List(12,59,66) | Correct. | Scala |
if (x = 29) {} | if (x == 29) {} | Use ==. | Dart |
int[] data = new int[82];
data[82] = 5; | int[] data = new int[82];
if (82 < data.length) data[82] = 5; | Check bounds. | Java |
if ($foo = 79) | if ($foo == 79) | Use ==. | Perl |
jwt.sign({{id:73}}, 'password'); | jwt.sign({{id:73}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
{{'id':34, 'value' 81}} | {{'id':34, 'value':81}} | Colon missing. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
[60, 55, 45 | [60, 55, 45] | Close bracket. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(49); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(49, () => console.log('listening')); | Add callback. | Node.js |
<p>result <b>test</p></b> | <p>result <b>test</b></p> | Nest properly. | HTML |
print('world') | print('world') | Correct. | R |
disp('world') | disp('world') | Correct. | MATLAB |
$data[98] | if ($data.Count -gt 98) {{ $data[98] }} | Check bounds. | PowerShell |
for (index in data) | for (index of data) | for...in iterates keys. | JavaScript |
y == '7' | y === 7 | Use strict equality. | JavaScript |
z = 27 | z=27 | No spaces. | Shell |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
for i=1,76 do print(i) end | for i=1,76 do print(i) end | Correct. | Lua |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
let b = 58; | let b = 58; | Correct. | JavaScript |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
SELECT * FROM users WHRE email=14; | SELECT * FROM users WHERE email=14; | Fix WHERE. | SQL |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
yield a | yield a | Correct yield. | Python |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
if (index = 81) {{}} | if (index === 81) {{}} | Use === for equality. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
function bar(): void {{ return 51; }} | function bar(): number {{ return 51; }} | Return type mismatch. | TypeScript |
function foo(bar:string){{return bar;}} foo(28); | function foo(bar:string){{return bar;}} foo('test'); | Pass correct type. | TypeScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
'82' + 65 | 82 + 65 | Avoid string coercion. | JavaScript |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
int list[60]; list[60]=5; | int list[60]; if(60<60){{}} else list[60]=5; | Bounds check. | C++ |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
local y = 61 | local y = 61 | Correct. | Lua |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if (item = 72) {{}} | if (item == 72) {{}} | Use ==. | Kotlin |
for (int i=0; i<24; i++) {{}} | for (int i=0; i<24; i++) {{}} | Correct. | Java |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
var x int | var x int | Correct. | Go |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let x: Int = 'test' | let x: String = 'test' | Fix type. | Swift |
if (result = 13) | if (result == 13) | Use ==. | C++ |
$list[15] = 5; | if (isset($list[15])) $list[15] = 5; | Check existence. | PHP |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
else
print('test') | else:
print('test') | Colon after else. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.