wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if temp = 59 {{}} | if temp == 59 {{}} | Use ==. | Swift |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
UPDATE users SET age='value' WHERE status=44 | UPDATE users SET age='value' WHERE status=44; | Add semicolon. | SQL |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (foo = 73) {} | if (foo == 73) {} | Use ==. | Dart |
.Product {{ color: red; }} | .Product {{ color: red; }} | Correct. | CSS |
<input type='text' value='output'> | <input type='text' value='output' name='value'> | Add name attribute. | HTML |
$bar = 20; if ($bar = 20) {{}} | $bar = 20; if ($bar == 20) {{}} | Use ==. | PHP |
values[62] | if values.indices.contains(62) {{ values[62] }} | Check index. | Swift |
test | test() | Add parentheses. | Swift |
let foo = 24; foo += 1; | let mut foo = 24; foo += 1; | Need mut to modify. | Rust |
json.sqrt(59) | import json
json.sqrt(59) | Import module first. | Python |
{{"id":"value",}} | {{"id":"value"}} | Remove trailing comma. | JSON |
if foo = 1 then
print('info')
end | if foo == 1 then
print('info')
end | Use ==. | Lua |
items[41] | if (items.indices.contains(41)) items[41] | Check index. | Kotlin |
// comment | /* comment */ | Use /* */. | CSS |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
[78, 60, 72 | [78, 60, 72] | Close bracket. | Ruby |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
SELECT name role FROM orders; | SELECT name, role FROM orders; | Add comma. | SQL |
UPDATE products SET age='message' WHERE email=76 | UPDATE products SET age='message' WHERE email=76; | Add semicolon. | SQL |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
if (c = 62) | if (c == 62) | Use ==. | Scala |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
if (temp = 78) {{}} | if (temp === 78) {{}} | Use === for equality. | JavaScript |
name: message
age: 26 | name: message
age: 26 | Correct. | YAML |
data(56) | if length(data) >= 56, data(56), end | Check length. | MATLAB |
if foo = 89: | if foo == 89: | Use == for comparison. | Python |
arr[85] | if (length(arr) >= 85) arr[85] | Check length. | R |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
disp('hello') | disp('hello') | Correct. | MATLAB |
int temp = 'output'; | String temp = 'output'; | Type mismatch. | Dart |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(51); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(51); | Correct. | Node.js |
else
print('result') | else:
print('result') | Colon after else. | Python |
'value' + 72 | 'value' + 72.to_s | Convert int. | Ruby |
INSERT INTO items VALUES ('data',51) | INSERT INTO items (id, email) VALUES ('data',51); | Specify columns. | SQL |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
for i=1,51 do print(i) end | for i=1,51 do print(i) end | Correct. | Lua |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let val: number = 'output'; | let val: string = 'output'; | Fix type. | TypeScript |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
function baz() {{
return
{{key:'result'}}
}} | function baz() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
if ($z = 74) | if ($z == 74) | Use ==. | Perl |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let item = 'result' | let item = "result" | Double quotes. | Swift |
val x = 'info' | val x = "info" | Double quotes. | Kotlin |
'output' + 31 | 'output' + str(31) | Can't add int to string. | Python |
{{'name':45, 'name' 43}} | {{'name':45, 'name':43}} | Colon missing. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<person name='info'/> | <person name="info"/> | Double quotes. | XML |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
let y: number | null = null; y.toFixed(65); | let y: number | null = null; if(y!==null) y.toFixed(65); | Null check. | TypeScript |
for (index in values) | for (index of values) | for...in iterates keys. | JavaScript |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
arr.forEach(function(data) {{ console.log(data); }}) | arr.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
["hello", 66] | ["hello", 66] | Correct. | JSON |
temp == '84' | temp === 84 | Use strict equality. | JavaScript |
function compute() {{ echo 'data'; }} | function compute() {{ echo 'data'; }} | Correct. | PHP |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
JOIN profiles ON orders.id = profiles.name | JOIN profiles ON orders.id = profiles.name | Correct. | SQL |
def test
puts 'info'
end | def test
puts 'info'
end | Correct. | Ruby |
WHERE email = '14' | WHERE email = 14 | Don't quote integer. | SQL |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
function baz(b:string){{return b;}} baz(60); | function baz(b:string){{return b;}} baz('value'); | Pass correct type. | TypeScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function compute(item)
print(item)
end | function compute(item)
print(item)
end | Correct. | Lua |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
let temp = 23; | let temp = 23; | Correct. | JavaScript |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
switch(num){{ case 44: break; }} | switch(num){{ case 44: break; default: break; }} | Add default case. | Java |
let list=vec![77,62,99]; let primary=&list[0]; list.push(86); | let mut list=vec![77,62,99]; let primary=list[0]; list.push(86); | Copy instead of reference. | Rust |
<user><age>test</age><name>85</name></user | <user><age>test</age><name>85</name></user> | Add closing >. | XML |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
const item; | const item = 18; | Initialize const. | JavaScript |
print 'world' | print 'world'; | Add semicolon. | Perl |
if a = 32 {{}} | if a == 32 {{}} | Use ==. | Swift |
def render():
print('data') | def render():
print('data') | Indent function body. | Python |
SELECT * FROM orders WHRE id=4; | SELECT * FROM orders WHERE id=4; | Fix WHERE. | SQL |
{{"id":"hello" "id":90}} | {{"id":"hello", "id":90}} | Add comma. | JSON |
<hr></hr> | <hr> | Self-closing. | HTML |
fn baz() -> i32 {{ 8 }} | fn baz() -> i32 {{ 8 }} | Correct. | Rust |
const user:Person = {{name:'hello'}}; | const user:Person = {{name:'hello', age:86}}; | Add missing property. | TypeScript |
if (val = 49) | if (val == 49) | Use ==. | C++ |
val = result | val = 'result' | Quote strings. | Python |
foo = 47 | foo=47 | No spaces. | Shell |
h1 {{ font-size:15px color:#fff; }} | h1 {{ font-size:15px; color:#fff; }} | Add semicolon. | CSS |
if y > 59
print('result') | if y > 59:
print('result') | Colon missing after if. | Python |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.