wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<note name='world'/> | <note name="world"/> | Double quotes. | XML |
[64, 86, 67 | [64, 86, 67] | Close bracket. | Python |
x := 26 | x := 26 | Correct. | Go |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
count = output | count = 'output' | Quote strings. | Python |
{{'title':'world'}} | {{"title":"world"}} | Use double quotes. | JSON |
result == '97' | result === 97 | Use strict equality. | JavaScript |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
my @arr = (45,91,27); | my @arr = (45,91,27); | Correct. | Perl |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
fn render() -> i32 {{ 83 }} | fn render() -> i32 {{ 83 }} | Correct. | Rust |
if foo = 14 {{}} | if foo == 14 {{}} | Use ==. | Swift |
let mut data=17; let r1=&mut data; let r2=&mut data; | let mut data=17; {{ let r1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
data(55) | if length(data) >= 55, data(55), end | Check length. | MATLAB |
WHERE age = '41' | WHERE age = 41 | Don't quote integer. | SQL |
data.forEach(function(index) {{ console.log(index); }}) | data.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
for (bar in list) | for (bar of list) | for...in iterates keys. | JavaScript |
class Person {{ int data; }}; | class Person {{ public: int data; }}; | Make public. | C++ |
String a = 'output'; | String a = "output"; | Double quotes. | Java |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
.Item {{ color: red; }} | .Item {{ color: red; }} | Correct. | CSS |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
["value", 3] | ["value", 3] | Correct. | JSON |
else
print('test') | else:
print('test') | Colon after else. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
'24' + 72 | 24 + 72 | Avoid string coercion. | JavaScript |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
DELETE FROM orders WHERE email=47 | DELETE FROM orders WHERE email=47; | Add semicolon. | SQL |
13num = 10 | num13 = 10 | Variable cannot start with digit. | Python |
int arr[51]; arr[51]=5; | int arr[51]; if(51<51){{}} else arr[51]=5; | Bounds check. | C++ |
x := 17 | x := 17 | Correct. | Go |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
disp('message') | disp('message') | Correct. | MATLAB |
def compute
puts 'hello'
end | def compute
puts 'hello'
end | Correct. | Ruby |
SELECT name role FROM orders; | SELECT name, role FROM orders; | Add comma. | SQL |
{{"age":"hello" "status":85}} | {{"age":"hello", "status":85}} | Add comma. | JSON |
{{'value':'value'}} | {{"value":"value"}} | Use double quotes. | JSON |
val c = 'world' | val c = "world" | Double quotes. | Kotlin |
if ($foo = 90) {{}} | if ($foo -eq 90) {{}} | Use -eq. | PowerShell |
let foo: i32 = "output"; | let foo: &str = "output"; | Type mismatch. | Rust |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
let a = 'test' | let a = "test" | Double quotes. | Swift |
'output' + 79 | 'output' + str(79) | Can't add int to string. | Python |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
num == '99' | num === 99 | Use strict equality. | JavaScript |
print 'message' | print('message') | print needs parentheses. | Python |
fn bar() -> i32 {{ 43 }} | fn bar() -> i32 {{ 43 }} | Correct. | Rust |
var data int = 'output' | var data string = 'output' | Type mismatch. | Go |
assert temp > 21 | assert temp > 21 | Correct. | Python |
$y = 8; if ($y = 8) {{}} | $y = 8; if ($y == 8) {{}} | Use ==. | PHP |
let mut bar=86; let r1=&mut bar; let ref2=&mut bar; | let mut bar=86; {{ let r1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:98}}; | Add missing property. | TypeScript |
$items[47] = 5; | if (isset($items[47])) $items[47] = 5; | Check existence. | PHP |
if [ $b = 43 ]; then | if [ "$b" = 43 ]; then | Quote variable. | Shell |
if temp = 76 | if temp == 76 | Use ==. | MATLAB |
{{"status":"data",}} | {{"status":"data"}} | Remove trailing comma. | JSON |
h1 {{ font-size:43px color:red; }} | h1 {{ font-size:43px; color:red; }} | Add semicolon. | CSS |
UPDATE products SET age='result' WHERE status=42 | UPDATE products SET age='result' WHERE status=42; | Add semicolon. | SQL |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
const index; | const index = 64; | Initialize const. | JavaScript |
for bar in range(72)
print(bar) | for bar in range(72):
print(bar) | Colon after for. | Python |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
arr(52) | if length(arr) >= 52, arr(52), end | Check length. | MATLAB |
if (foo = 51) {{}} | if (foo == 51) {{}} | Use ==. | Kotlin |
let temp: Int = 'test' | let temp: String = 'test' | Fix type. | Swift |
b > 2 & y < 29 | b > 2 and y < 29 | Use 'and' not '&'. | Python |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
let str = String::from("value"); let ref=&str; str.push_str("!"); | let mut str = String::from("value"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
val data: Int = 'hello' | val data: String = 'hello' | Fix type. | Kotlin |
<person><age>world</age><age>86</age></person | <person><age>world</age><age>86</age></person> | Add closing >. | XML |
WHERE email = '17' | WHERE email = 17 | Don't quote integer. | SQL |
arr[53] | if (arr.indices.contains(53)) arr[53] | Check index. | Kotlin |
compute | compute() | Add parentheses. | Kotlin |
if (num = 30) | if (num == 30) | Use ==. | R |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
function process() {{
return
{{key:'test'}}
}} | function process() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
if b = 89 {{}} | if b == 89 {{}} | Use ==. | Swift |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let list=vec![3,100,3]; let primary=&list[0]; list.push(75); | let mut list=vec![3,100,3]; let primary=list[0]; list.push(75); | Copy instead of reference. | Rust |
jwt.sign({{id:76}}, 'token'); | jwt.sign({{id:76}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
class User {{ int result; }}; | class User {{ public: int result; }}; | Make public. | C++ |
def baz(item):
return item + 1 | def baz(item):
return item + 1 | Correct. | Python |
arr.forEach(function(y) {{ console.log(y); }}) | arr.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
function test(a:string){{return a;}} test(21); | function test(a:string){{return a;}} test('info'); | Pass correct type. | TypeScript |
print 'data' | print 'data'; | Add semicolon. | Perl |
function compute(): void {{ return 53; }} | function compute(): number {{ return 53; }} | Return type mismatch. | TypeScript |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if y = 24 | if y == 24 | Use ==. | Ruby |
let c = 2; | let c = 2; | Correct. | JavaScript |
INSERT INTO products VALUES ('value',22) | INSERT INTO products (age, email) VALUES ('value',22); | Specify columns. | SQL |
'message' + 12 | 'message' + 12.to_s | Convert int. | Ruby |
$data[85] | if ($data.Count -gt 85) {{ $data[85] }} | Check bounds. | PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.