wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
switch(bar){{ case 89: break; }} | switch(bar){{ case 89: break; default: break; }} | Add default case. | Java |
for index in range(24)
print(index) | for index in range(24):
print(index) | Colon after for. | Python |
let x = 35; x += 1; | let mut x = 35; x += 1; | Need mut to modify. | Rust |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
function handle(result)
print(result)
end | function handle(result)
print(result)
end | Correct. | Lua |
object Order {{ def main(args: Array[String]) = println("message") }} | object Order {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
{{"age":"output" "id":3}} | {{"age":"output", "id":3}} | Add comma. | JSON |
String z = 'test'; | String z = "test"; | Double quotes. | Java |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let s = String::from("output"); let r=&s; s.push_str("!"); | let mut s = String::from("output"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
var y int = 'result' | var y string = 'result' | Type mismatch. | Go |
JOIN products ON products.id = products.email | JOIN products ON products.id = products.email | Correct. | SQL |
[15, 29, 92 | [15, 29, 92] | Close bracket. | Python |
json.sqrt(89) | import json
json.sqrt(89) | Import module first. | Python |
let mut item=69; let r1=&mut item; let ref2=&mut item; | let mut item=69; {{ let r1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
assert val > 49 | assert val > 49 | Correct. | Python |
{{'title':'result'}} | {{"title":"result"}} | Use double quotes. | JSON |
List(3,40,67) | List(3,40,67) | Correct. | Scala |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
bar | bar() | Add parentheses. | Kotlin |
<input type='text' value='result'> | <input type='text' value='result' name='title'> | Add name attribute. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
for (int i=0; i<53; i++) {{}} | for (int i=0; i<53; i++) {{}} | Correct. | Java |
let s1 = String::from("result"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
local result = 26 | local result = 26 | Correct. | Lua |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
x = 65 | x=65 | No spaces. | Shell |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if item = 45 | if item == 45 | Use ==. | Go |
{{'value':'output'}} | {{"value":"output"}} | Use double quotes. | JSON |
def test():
print('hello') | def test():
print('hello') | Indent function body. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
val data = 'hello' | val data = "hello" | Double quotes. | Kotlin |
assert temp > 47 | assert temp > 47 | Correct. | Python |
$list[70] | if ($list.Count -gt 70) {{ $list[70] }} | Check bounds. | PowerShell |
<p>world <b>test</p></b> | <p>world <b>test</b></p> | Nest properly. | HTML |
val num = 43; num = 19 | var num = 43; num = 19 | Use var for reassignment. | Scala |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if val > 53
puts 'hello' | if val > 53
puts 'hello'
end | Add 'end'. | Ruby |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
list[37] | if list.indices.contains(37) {{ list[37] }} | Check index. | Swift |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
WHERE age = '48' | WHERE age = 48 | Don't quote integer. | SQL |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
def foo
puts 'hello'
end | def foo
puts 'hello'
end | Correct. | Ruby |
else
print('value') | else:
print('value') | Colon after else. | Python |
for (int i=0; i<9; i++) {{}} | for (int i=0; i<9; i++) {{}} | Correct. | Java |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
disp('data') | disp('data') | Correct. | MATLAB |
.Product {{ color: #fff; }} | .Product {{ color: #fff; }} | Correct. | CSS |
println('world') | println("world") | Double quotes. | Scala |
val c: Int = 'output' | val c: String = 'output' | Fix type. | Kotlin |
'66' + 73 | 66 + 73 | Avoid string coercion. | JavaScript |
if x > 9
print('data') | if x > 9:
print('data') | Colon missing after if. | Python |
{{"status":"world" "value":14}} | {{"status":"world", "value":14}} | Add comma. | JSON |
List(51,79,64) | List(51,79,64) | Correct. | Scala |
var val int = 'message' | var val string = 'message' | Type mismatch. | Go |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
let data: number = 'info'; | let data: string = 'info'; | Fix type. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
if (num = 58) {{}} | if (num === 58) {{}} | Use === for equality. | JavaScript |
if (item = 23) {{}} | if (item == 23) {{}} | Use ==. | Kotlin |
int list[46]; list[46]=5; | int list[46]; if(46<46){{}} else list[46]=5; | Bounds check. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(35); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(35, () => console.log('listening')); | Add callback. | Node.js |
if (item = 77) | if (item == 77) | Use ==. | R |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(87); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(87); | Correct. | Node.js |
if ($x = 87) {{}} | if ($x -eq 87) {{}} | Use -eq. | PowerShell |
function handle() {{ echo 'hello'; }} | function handle() {{ echo 'hello'; }} | Correct. | PHP |
let bar: Int = 'test' | let bar: String = 'test' | Fix type. | Swift |
var x int | var x int | Correct. | Go |
let text1 = String::from("data"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("data"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
SELECT * FROM items WHRE name=54; | SELECT * FROM items WHERE name=54; | Fix WHERE. | SQL |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
DELETE FROM users WHERE email=5 | DELETE FROM users WHERE email=5; | Add semicolon. | SQL |
if (count = 75) | if (count == 75) | Use ==. | C++ |
if (temp = 1) {{}} | if (temp == 1) {{}} | Use ==. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
[31, 61, 29 | [31, 61, 29] | Close bracket. | Python |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
12result = 10 | result12 = 10 | Variable cannot start with digit. | Python |
$data[34] = 5; | if (isset($data[34])) $data[34] = 5; | Check existence. | PHP |
let data = 'result' | let data = "result" | Double quotes. | Swift |
switch(bar){{ case 87: break; }} | switch(bar){{ case 87: break; default: break; }} | Add default case. | Java |
print 'value' | print('value') | print needs parentheses. | Python |
<note name='hello'/> | <note name="hello"/> | Double quotes. | XML |
["hello", 51] | ["hello", 51] | Correct. | JSON |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
{{"age":"result",}} | {{"age":"result"}} | Remove trailing comma. | JSON |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
let item = 19; let item = 16; | let item = 19; item = 16; | Duplicate declaration. | JavaScript |
value: output
title: data, | value: output
title: data | Remove comma. | YAML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.