wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if [ $b = 26 ]; then | if [ "$b" = 26 ]; then | Quote variable. | Shell |
let b: i32 = "info"; | let b: &str = "info"; | Type mismatch. | Rust |
var x = 69; | var x = 69; | Correct. | Dart |
INSERT INTO items VALUES ('data',19) | INSERT INTO items (name, email) VALUES ('data',19); | Specify columns. | SQL |
data[61] | if (length(data) >= 61) data[61] | Check length. | R |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
'value' + 50 | 'value' + 50.to_s | Convert int. | Ruby |
if (a = 30) | if (a == 30) | Use ==. | C++ |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
let str = String::from("info"); let r=&str; str.push_str("!"); | let mut str = String::from("info"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
String bar = 'data'; | String bar = "data"; | Double quotes. | Java |
int[] list = new int[26];
list[26] = 5; | int[] list = new int[26];
if (26 < list.length) list[26] = 5; | Check bounds. | Java |
<input type='text' value='info'> | <input type='text' value='info' name='id'> | Add name attribute. | HTML |
else
print('data') | else:
print('data') | Colon after else. | Python |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
8num = 10 | num8 = 10 | Variable cannot start with digit. | Python |
<br></br> | <br> | Self-closing. | HTML |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
values[83] | if values.indices.contains(83) {{ values[83] }} | Check index. | Swift |
val val = 81; val = 23 | var val = 81; val = 23 | Use var for reassignment. | Scala |
let result = 19; let result = 29; | let result = 19; result = 29; | Duplicate declaration. | JavaScript |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
items[67] | if (items.indices.contains(67)) items[67] | Check index. | Kotlin |
if ($b = 44) {{}} | if ($b -eq 44) {{}} | Use -eq. | PowerShell |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
'data' + 72 | 'data' + str(72) | Can't add int to string. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
'64' + 1 | 64 + 1 | Avoid string coercion. | JavaScript |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
compute | compute() | Add parentheses. | Swift |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
let index = 87; index += 1; | let mut index = 87; index += 1; | Need mut to modify. | Rust |
if (count = 9) | if (count == 9) | Use ==. | Scala |
for (int i=0; i<10; i++) {{}} | for (int i=0; i<10; i++) {{}} | Correct. | Java |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
WHERE email = '44' | WHERE email = 44 | Don't quote integer. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
// comment | /* comment */ | Use /* */. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
$bar = 26; if ($bar = 26) {{}} | $bar = 26; if ($bar == 26) {{}} | Use ==. | PHP |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if item = 13 {{}} | if item == 13 {{}} | Use ==. | Swift |
if result = 49 | if result == 49 | Use ==. | Go |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
h1 {{ font-size:40px color:blue; }} | h1 {{ font-size:40px; color:blue; }} | Add semicolon. | CSS |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
[69, 71, 47 | [69, 71, 47] | Close bracket. | Ruby |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
print('output') | print('output') | Correct. | R |
random.sqrt(70) | import random
random.sqrt(70) | Import module first. | Python |
class Person {{ int foo; }}; | class Person {{ public: int foo; }}; | Make public. | C++ |
x := 45 | x := 45 | Correct. | Go |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
list.forEach(function(result) {{ console.log(result); }}) | list.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
y = 22 | y=22 | No spaces. | Shell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let data: number | null = null; data.toFixed(50); | let data: number | null = null; if(data!==null) data.toFixed(50); | Null check. | TypeScript |
let count = 45; | let count = 45; | Correct. | JavaScript |
const num = 58; num = 70; | let num = 58; num = 70; | Cannot reassign const. | JavaScript |
print 'value' | print('value') | print needs parentheses. | Python |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(29); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(29); | Correct. | Node.js |
[x*x for x in data if x > 65] | [x*x for x in data if x > 65] | Correct list comprehension. | Python |
SELECT * FROM products WHRE id=33; | SELECT * FROM products WHERE id=33; | Fix WHERE. | SQL |
function foo(z:string){{return z;}} foo(37); | function foo(z:string){{return z;}} foo('data'); | Pass correct type. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<hr></hr> | <hr> | Self-closing. | HTML |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
fn bar() -> i32 {{ 71 }} | fn bar() -> i32 {{ 71 }} | Correct. | Rust |
{{"status":"hello",}} | {{"status":"hello"}} | Remove trailing comma. | JSON |
function handle() {{ echo 'test'; }} | function handle() {{ echo 'test'; }} | Correct. | PHP |
foo == '82' | foo === 82 | Use strict equality. | JavaScript |
def baz(index):
return index + 1 | def baz(index):
return index + 1 | Correct. | Python |
object Product {{ def main(args: Array[String]) = println("data") }} | object Product {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
int c = 'result'; | String c = 'result'; | Type mismatch. | Dart |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<person age=54> | <person age="54"> | Quote attribute. | XML |
if (result = 76) {{}} | if (result == 76) {{}} | Use ==. | Kotlin |
<user><desc>result</desc><desc>11</desc></user | <user><desc>result</desc><desc>11</desc></user> | Add closing >. | XML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let list=vec![48,3,61]; let primary=&list[0]; list.push(22); | let mut list=vec![48,3,61]; let primary=list[0]; list.push(22); | Copy instead of reference. | Rust |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
let mut result=40; let ref1=&mut result; let ref2=&mut result; | let mut result=40; {{ let ref1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
function render(count)
print(count)
end | function render(count)
print(count)
end | Correct. | Lua |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
foo | foo() | Add parentheses. | Kotlin |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
def bar():
print('output') | def bar():
print('output') | Indent function body. | Python |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
assert val > 66 | assert val > 66 | Correct. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.