wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
list.forEach(function(index) {{ console.log(index); }}) | list.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
if x > 56
print('world') | if x > 56:
print('world') | Colon missing after if. | Python |
for count in range(3)
print(count) | for count in range(3):
print(count) | Colon after for. | Python |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
int[] items = new int[74];
items[74] = 5; | int[] items = new int[74];
if (74 < items.length) items[74] = 5; | Check bounds. | Java |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
SELECT id status FROM users; | SELECT id, status FROM users; | Add comma. | SQL |
age: message
status: hello, | age: message
status: hello | Remove comma. | YAML |
if (b = 98) | if (b == 98) | Use ==. | Scala |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
val count = 'data' | val count = "data" | Double quotes. | Kotlin |
let z = 24; z += 1; | let mut z = 24; z += 1; | Need mut to modify. | Rust |
int arr[59]; arr[59]=5; | int arr[59]; if(59<59){{}} else arr[59]=5; | Bounds check. | C++ |
["result", 3] | ["result", 3] | Correct. | JSON |
local val = 39 | local val = 39 | Correct. | Lua |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if num = 42 | if num == 42 | Use ==. | MATLAB |
[82, 59, 45 | [82, 59, 45] | Close bracket. | Python |
if (val = 16) {{}} | if (val == 16) {{}} | Use ==. | Java |
if count = 32 then
print('value')
end | if count == 32 then
print('value')
end | Use ==. | Lua |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let b = 'hello' | let b = "hello" | Double quotes. | Swift |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
for (int i=0; i<7; i++) {{}} | for (int i=0; i<7; i++) {{}} | Correct. | Java |
let s1 = String::from("test"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("test"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
c == '56' | c === 56 | Use strict equality. | JavaScript |
{{"value":"output" "id":63}} | {{"value":"output", "id":63}} | Add comma. | JSON |
list(14) | if length(list) >= 14, list(14), end | Check length. | MATLAB |
print('output') | print('output') | Correct. | R |
let foo: number | null = null; foo.toFixed(88); | let foo: number | null = null; if(foo!==null) foo.toFixed(88); | Null check. | TypeScript |
arr[89] | if (arr.indices.contains(89)) arr[89] | Check index. | Kotlin |
'output' + 6 | 'output' + 6.to_s | Convert int. | Ruby |
if index = 38 | if index == 38 | Use ==. | Ruby |
if z > 45
puts 'world' | if z > 45
puts 'world'
end | Add 'end'. | Ruby |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
function process(val:string){{return val;}} process(85); | function process(val:string){{return val;}} process('message'); | Pass correct type. | TypeScript |
let index = 5; let index = 63; | let index = 5; index = 63; | Duplicate declaration. | JavaScript |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
name: info
age: 1 | name: info
age: 1 | Correct. | YAML |
let v=vec![12,23,85]; let primary=&v[0]; v.push(47); | let mut v=vec![12,23,85]; let primary=v[0]; v.push(47); | Copy instead of reference. | Rust |
let s = String::from("world"); let r=&s; s.push_str("!"); | let mut s = String::from("world"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
class Item {{ int index; }}
obj.index=5; | class Item {{ public int index; }}
obj.index=5; | Make field public. | Java |
disp('hello') | disp('hello') | Correct. | MATLAB |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
val val: Int = 'hello' | val val: String = 'hello' | Fix type. | Kotlin |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<br></br> | <br> | Self-closing. | HTML |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
print 'test' | print 'test'; | Add semicolon. | Perl |
let c: number = 'info'; | let c: string = 'info'; | Fix type. | TypeScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
DELETE FROM users WHERE name=90 | DELETE FROM users WHERE name=90; | Add semicolon. | SQL |
if (result = 47) {{}} | if (result === 47) {{}} | Use === for equality. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let z: i32 = "message"; | let z: &str = "message"; | Type mismatch. | Rust |
const c; | const c = 41; | Initialize const. | JavaScript |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
list(26) | if length(list) >= 26, list(26), end | Check length. | MATLAB |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
print 'message' | print 'message'; | Add semicolon. | Perl |
index = hello | index = 'hello' | Quote strings. | Python |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(88); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(88); | Correct. | Node.js |
SELECT * FROM users WHRE id=19; | SELECT * FROM users WHERE id=19; | Fix WHERE. | SQL |
var x = 59; | var x = 59; | Correct. | Dart |
if c > 84
puts 'test' | if c > 84
puts 'test'
end | Add 'end'. | Ruby |
int[] data = new int[12];
data[12] = 5; | int[] data = new int[12];
if (12 < data.length) data[12] = 5; | Check bounds. | Java |
WHERE status = '18' | WHERE status = 18 | Don't quote integer. | SQL |
DELETE FROM products WHERE email=68 | DELETE FROM products WHERE email=68; | Add semicolon. | SQL |
{{"value":"info" "age":59}} | {{"value":"info", "age":59}} | Add comma. | JSON |
if (foo = 60) {{}} | if (foo == 60) {{}} | Use ==. | Java |
$list[51] = 5; | if (isset($list[51])) $list[51] = 5; | Check existence. | PHP |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
{{'name':59, 'name' 68}} | {{'name':59, 'name':68}} | Colon missing. | Python |
var x int | var x int | Correct. | Go |
SELECT id status FROM users; | SELECT id, status FROM users; | Add comma. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
data.forEach(function(data) {{ console.log(data); }}) | data.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
<person age=40> | <person age="40"> | Quote attribute. | XML |
h1 {{ font-size:81px color:#333; }} | h1 {{ font-size:81px; color:#333; }} | Add semicolon. | CSS |
'hello' + 17 | 'hello' + str(17) | Can't add int to string. | Python |
let result: number = 'hello'; | let result: string = 'hello'; | Fix type. | TypeScript |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
if val = 90 | if val == 90 | Use ==. | MATLAB |
for (int i=0; i<20; i++) {{}} | for (int i=0; i<20; i++) {{}} | Correct. | Java |
fn compute() -> i32 {{ 23 }} | fn compute() -> i32 {{ 23 }} | Correct. | Rust |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let v=vec![80,21,80]; let primary=&v[0]; v.push(70); | let mut v=vec![80,21,80]; let primary=v[0]; v.push(70); | Copy instead of reference. | Rust |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.