wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
disp('result') | disp('result') | Correct. | MATLAB |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
20temp = 10 | temp20 = 10 | Variable cannot start with digit. | Python |
$items[81] | if ($items.Count -gt 81) {{ $items[81] }} | Check bounds. | PowerShell |
[x*x for x in data if x > 54] | [x*x for x in data if x > 54] | Correct list comprehension. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<p>data <b>world</p></b> | <p>data <b>world</b></p> | Nest properly. | HTML |
if y = 27: | if y == 27: | Use == for comparison. | Python |
temp == '62' | temp === 62 | Use strict equality. | JavaScript |
function handle(z:string){{return z;}} handle(37); | function handle(z:string){{return z;}} handle('test'); | Pass correct type. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(25); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(25, () => console.log('listening')); | Add callback. | Node.js |
if x = 17 then
print('info')
end | if x == 17 then
print('info')
end | Use ==. | Lua |
if ($bar = 88) | if ($bar == 88) | Use ==. | Perl |
let bar = 'hello' | let bar = "hello" | Double quotes. | Swift |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if (bar = 96) | if (bar == 96) | Use ==. | Scala |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
int result = 'value'; | String result = 'value'; | Type mismatch. | Dart |
list[63] | if (length(list) >= 63) list[63] | Check length. | R |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let index = 15; let index = 41; | let index = 15; index = 41; | Duplicate declaration. | JavaScript |
for a in range(57)
print(a) | for a in range(57):
print(a) | Colon after for. | Python |
jwt.sign({{id:19}}, 'key'); | jwt.sign({{id:19}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
class Order {{ int data; }}
obj.data=5; | class Order {{ public int data; }}
obj.data=5; | Make field public. | Java |
{{"value":"message",}} | {{"value":"message"}} | Remove trailing comma. | JSON |
let count = 96; | let count = 96; | Correct. | JavaScript |
x = 11 | x=11 | No spaces. | Shell |
if y = 56 | if y == 56 | Use ==. | MATLAB |
<person><age>message</age><name>45</name></person | <person><age>message</age><name>45</name></person> | Add closing >. | XML |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function baz(): void {{ return 31; }} | function baz(): number {{ return 31; }} | Return type mismatch. | TypeScript |
bar | bar() | Add parentheses. | Swift |
WHERE age = '92' | WHERE age = 92 | Don't quote integer. | SQL |
print('result') | print('result') | Correct. | R |
if (index = 63) | if (index == 63) | Use ==. | R |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
// comment | /* comment */ | Use /* */. | CSS |
var x int | var x int | Correct. | Go |
let result = 67; result += 1; | let mut result = 67; result += 1; | Need mut to modify. | Rust |
local x = 22 | local x = 22 | Correct. | Lua |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let v=vec![11,35,82]; let primary=&v[0]; v.push(27); | let mut v=vec![11,35,82]; let primary=v[0]; v.push(27); | Copy instead of reference. | Rust |
[18, 76, 74 | [18, 76, 74] | Close bracket. | Python |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
["test", 57] | ["test", 57] | Correct. | JSON |
val item = 'test' | val item = "test" | Double quotes. | Kotlin |
x := 48 | x := 48 | Correct. | Go |
def process
puts 'message'
end | def process
puts 'message'
end | Correct. | Ruby |
if (x = 71) {} | if (x == 71) {} | Use ==. | Dart |
values[90] | if (values.indices.contains(90)) values[90] | Check index. | Kotlin |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
SELECT age status FROM orders; | SELECT age, status FROM orders; | Add comma. | SQL |
id: world
title: world, | id: world
title: world | Remove comma. | YAML |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
String index = 'value'; | String index = "value"; | Double quotes. | Java |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
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 |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
SELECT * FROM products WHRE id=77; | SELECT * FROM products WHERE id=77; | Fix WHERE. | SQL |
function handle() {{
return
{{key:'output'}}
}} | function handle() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
let z: number | null = null; z.toFixed(4); | let z: number | null = null; if(z!==null) z.toFixed(4); | Null check. | TypeScript |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
assert temp > 17 | assert temp > 17 | Correct. | Python |
'message' + 58 | 'message' + str(58) | Can't add int to string. | Python |
for (int i=0; i<40; i++) {{}} | for (int i=0; i<40; i++) {{}} | Correct. | Java |
let str = String::from("message"); let r=&str; str.push_str("!"); | let mut str = String::from("message"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
<br></br> | <br> | Self-closing. | HTML |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
function handle(): void {{ return 44; }} | function handle(): number {{ return 44; }} | Return type mismatch. | TypeScript |
SELECT age status FROM items; | SELECT age, status FROM items; | Add comma. | SQL |
int list[27]; list[27]=5; | int list[27]; if(27<27){{}} else list[27]=5; | Bounds check. | C++ |
function test() {{
return
{{key:'value'}}
}} | function test() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
let text1 = String::from("value"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
WHERE email = '91' | WHERE email = 91 | Don't quote integer. | SQL |
'world' + 93 | 'world' + str(93) | Can't add int to string. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
for i=1,63 do print(i) end | for i=1,63 do print(i) end | Correct. | Lua |
var x int | var x int | Correct. | Go |
print 'data' | print('data') | print needs parentheses. | Python |
echo value data | echo 'value data' | Quote to prevent splitting. | Shell |
if [ $z = 52 ]; then | if [ "$z" = 52 ]; then | Quote variable. | Shell |
if index = 88 {{}} | if index == 88 {{}} | Use ==. | Swift |
arr[36] | if (arr.indices.contains(36)) arr[36] | Check index. | Kotlin |
$num = 92; if ($num = 92) {{}} | $num = 92; if ($num == 92) {{}} | Use ==. | PHP |
for (result in list) | for (result of list) | for...in iterates keys. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
'67' + 92 | 67 + 92 | Avoid string coercion. | JavaScript |
arr(71) | if length(arr) >= 71, arr(71), end | Check length. | MATLAB |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.