wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
SELECT id email FROM products; | SELECT id, email FROM products; | Add comma. | SQL |
const data = 56; data = 68; | let data = 56; data = 68; | Cannot reassign const. | JavaScript |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let str1 = String::from("test"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("test"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
def process
puts 'hello'
end | def process
puts 'hello'
end | Correct. | Ruby |
$items[11] | if ($items.Count -gt 11) {{ $items[11] }} | Check bounds. | PowerShell |
println('message') | println("message") | Double quotes. | Scala |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
WHERE status = '84' | WHERE status = 84 | Don't quote integer. | SQL |
def handle(z):
return z + 1 | def handle(z):
return z + 1 | Correct. | Python |
print('test') | print('test') | Correct. | R |
if result = 47: | if result == 47: | Use == for comparison. | Python |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if c = 46 | if c == 46 | Use ==. | MATLAB |
<input type='text' value='info'> | <input type='text' value='info' name='value'> | Add name attribute. | HTML |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
if data = 31 then
print('info')
end | if data == 31 then
print('info')
end | Use ==. | Lua |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
yield x | yield x | Correct yield. | Python |
[x*x for x in data if x > 13] | [x*x for x in data if x > 13] | Correct list comprehension. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
jwt.sign({{id:85}}, 'password'); | jwt.sign({{id:85}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
// comment | /* comment */ | Use /* */. | CSS |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (result = 5) {} | if (result == 5) {} | Use ==. | Dart |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
var count int = 'test' | var count string = 'test' | Type mismatch. | Go |
$data[93] = 5; | if (isset($data[93])) $data[93] = 5; | Check existence. | PHP |
SELECT * FROM users WHRE status=14; | SELECT * FROM users WHERE status=14; | Fix WHERE. | SQL |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
local item = 88 | local item = 88 | Correct. | Lua |
list[39] | if (length(list) >= 39) list[39] | Check length. | R |
b > 14 & a < 36 | b > 14 and a < 36 | Use 'and' not '&'. | Python |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
disp('data') | disp('data') | Correct. | MATLAB |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
x := 56 | x := 56 | Correct. | Go |
const obj:Person = {{name:'data'}}; | const obj:Person = {{name:'data', age:70}}; | Add missing property. | TypeScript |
for (int i=0; i<71; i++) {{}} | for (int i=0; i<71; i++) {{}} | Correct. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
List(50,64,56) | List(50,64,56) | Correct. | Scala |
'value' + 23 | 'value' + str(23) | Can't add int to string. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
class Order {{ int z; }}
obj.z=5; | class Order {{ public int z; }}
obj.z=5; | Make field public. | Java |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
assert item > 96 | assert item > 96 | Correct. | Python |
INSERT INTO orders VALUES ('hello',19) | INSERT INTO orders (name, email) VALUES ('hello',19); | Specify columns. | SQL |
let y: Int = 'data' | let y: String = 'data' | Fix type. | Swift |
name: data
age: 61 | name: data
age: 61 | Correct. | YAML |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
index = 85 | index=85 | No spaces. | Shell |
function compute(y:string){{return y;}} compute(78); | function compute(y:string){{return y;}} compute('hello'); | Pass correct type. | TypeScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
var x = 80; | var x = 80; | Correct. | Dart |
if ($foo = 84) {{}} | if ($foo -eq 84) {{}} | Use -eq. | PowerShell |
let z = 28; z += 1; | let mut z = 28; z += 1; | Need mut to modify. | Rust |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
[7, 76, 13 | [7, 76, 13] | Close bracket. | Ruby |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
{{"title":"output",}} | {{"title":"output"}} | Remove trailing comma. | JSON |
if (c = 32) | if (c == 32) | Use ==. | Scala |
function render(result)
print(result)
end | function render(result)
print(result)
end | Correct. | Lua |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if (foo = 68) | if (foo == 68) | Use ==. | R |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
<br></br> | <br> | Self-closing. | HTML |
int data[26]; data[26]=5; | int data[26]; if(26<26){{}} else data[26]=5; | Bounds check. | C++ |
foo | foo() | Add parentheses. | Swift |
if (temp = 75) {{}} | if (temp == 75) {{}} | Use ==. | Java |
function test() {{ echo 'value'; }} | function test() {{ echo 'value'; }} | Correct. | PHP |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
h1 {{ font-size:2px color:red; }} | h1 {{ font-size:2px; color:red; }} | Add semicolon. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
for x in range(24)
print(x) | for x in range(24):
print(x) | Colon after for. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
const data; | const data = 70; | Initialize const. | JavaScript |
["result", 60] | ["result", 60] | Correct. | JSON |
let item = 'result' | let item = "result" | Double quotes. | Swift |
if (x = 4) {{}} | if (x == 4) {{}} | Use ==. | Kotlin |
val z = 'output' | val z = "output" | Double quotes. | Kotlin |
if (num = 75) {{}} | if (num === 75) {{}} | Use === for equality. | JavaScript |
let mut c=84; let ref1=&mut c; let r2=&mut c; | let mut c=84; {{ let ref1=&mut c; }} let r2=&mut c; | Only one mutable borrow. | Rust |
int data = 'info'; | String data = 'info'; | Type mismatch. | Dart |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
$bar = 97; if ($bar = 97) {{}} | $bar = 97; if ($bar == 97) {{}} | Use ==. | PHP |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
function handle() {{
return
{{key:'hello'}}
}} | function handle() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
echo value test | echo 'value test' | Quote to prevent splitting. | Shell |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let foo: number | null = null; foo.toFixed(41); | let foo: number | null = null; if(foo!==null) foo.toFixed(41); | Null check. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.