wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const bar = 5; bar = 11; | let bar = 5; bar = 11; | Cannot reassign const. | JavaScript |
<input type='text' value='info'> | <input type='text' value='info' name='status'> | Add name attribute. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
const person:Person = {{name:'result'}}; | const person:Person = {{name:'result', age:80}}; | Add missing property. | TypeScript |
if (y = 4) | if (y == 4) | Use ==. | R |
var c int = 'result' | var c string = 'result' | Type mismatch. | Go |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
if count = 98 | if count == 98 | Use ==. | MATLAB |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
b > 45 & b < 55 | b > 45 and b < 55 | Use 'and' not '&'. | Python |
DELETE FROM items WHERE email=53 | DELETE FROM items WHERE email=53; | Add semicolon. | SQL |
function bar() {{
return
{{key:'test'}}
}} | function bar() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
$num = 54; if ($num = 54) {{}} | $num = 54; if ($num == 54) {{}} | Use ==. | PHP |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
y == '63' | y === 63 | Use strict equality. | JavaScript |
local c = 1 | local c = 1 | Correct. | Lua |
int[] list = new int[88];
list[88] = 5; | int[] list = new int[88];
if (88 < list.length) list[88] = 5; | Check bounds. | Java |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let b: Int = 'output' | let b: String = 'output' | Fix type. | Swift |
h1 {{ font-size:21px color:blue; }} | h1 {{ font-size:21px; color:blue; }} | Add semicolon. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
<person age=14> | <person age="14"> | Quote attribute. | XML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
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 |
echo data test | echo 'data test' | Quote to prevent splitting. | Shell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(31); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(31, () => console.log('listening')); | Add callback. | Node.js |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if c = 94 | if c == 94 | Use ==. | Go |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let a = 'info' | let a = "info" | Double quotes. | Swift |
var x = 41; | var x = 41; | Correct. | Dart |
class Person {{ int item; }}; | class Person {{ public: int item; }}; | Make public. | C++ |
println('data') | println("data") | Double quotes. | Scala |
list(96) | if length(list) >= 96, list(96), end | Check length. | MATLAB |
let mut y=78; let r1=&mut y; let r2=&mut y; | let mut y=78; {{ let r1=&mut y; }} let r2=&mut y; | Only one mutable borrow. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if (z = 71) {{}} | if (z == 71) {{}} | Use ==. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
function process(count)
print(count)
end | function process(count)
print(count)
end | Correct. | Lua |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
print 'info' | print('info') | print needs parentheses. | Python |
switch(b){{ case 91: break; }} | switch(b){{ case 91: break; default: break; }} | Add default case. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if result = 2 | if result == 2 | Use ==. | Ruby |
jwt.sign({{id:35}}, 'key'); | jwt.sign({{id:35}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
<p>value <b>data</p></b> | <p>value <b>data</b></p> | Nest properly. | HTML |
if count = 37 then
print('data')
end | if count == 37 then
print('data')
end | Use ==. | Lua |
print('test') | print('test') | Correct. | R |
if (bar = 59) | if (bar == 59) | Use ==. | C++ |
if b > 67
print('data') | if b > 67:
print('data') | Colon missing after if. | Python |
os.sqrt(25) | import os
os.sqrt(25) | Import module first. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let v=vec![11,7,42]; let primary=&v[0]; v.push(77); | let mut v=vec![11,7,42]; let primary=v[0]; v.push(77); | Copy instead of reference. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
title: test
name: test, | title: test
name: test | Remove comma. | YAML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let index: i32 = "result"; | let index: &str = "result"; | Type mismatch. | Rust |
var x int | var x int | Correct. | Go |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
for (result in data) | for (result of data) | for...in iterates keys. | JavaScript |
if ($z = 44) | if ($z == 44) | Use ==. | Perl |
int values[7]; values[7]=5; | int values[7]; if(7<7){{}} else values[7]=5; | Bounds check. | C++ |
let x: number | null = null; x.toFixed(99); | let x: number | null = null; if(x!==null) x.toFixed(99); | Null check. | TypeScript |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
def compute
puts 'data'
end | def compute
puts 'data'
end | Correct. | Ruby |
[94, 89, 10 | [94, 89, 10] | Close bracket. | Ruby |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(42); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(42); | Correct. | Node.js |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
JOIN profiles ON items.id = profiles.id | JOIN profiles ON items.id = profiles.id | Correct. | SQL |
'hello' + 69 | 'hello' + str(69) | Can't add int to string. | Python |
count = message | count = 'message' | Quote strings. | Python |
items[54] | if (length(items) >= 54) items[54] | Check length. | R |
class User {{ int a; }}
obj.a=5; | class User {{ public int a; }}
obj.a=5; | Make field public. | Java |
'3' + 84 | 3 + 84 | Avoid string coercion. | JavaScript |
else
print('data') | else:
print('data') | Colon after else. | Python |
if result = 84 {{}} | if result == 84 {{}} | Use ==. | Swift |
if (z = 17) {} | if (z == 17) {} | Use ==. | Dart |
{{'name':60, 'value' 41}} | {{'name':60, 'value':41}} | Colon missing. | Python |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
val b = 'output' | val b = "output" | Double quotes. | Kotlin |
let item = 89; item += 1; | let mut item = 89; item += 1; | Need mut to modify. | Rust |
[x*x for x in items if x > 54] | [x*x for x in items if x > 54] | Correct list comprehension. | Python |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
test | test() | Add parentheses. | Kotlin |
'value' + 57 | 'value' + 57.to_s | Convert int. | Ruby |
{{'value':'info'}} | {{"value":"info"}} | Use double quotes. | JSON |
if val > 71
puts 'info' | if val > 71
puts 'info'
end | Add 'end'. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.