wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
String val = 'info'; | String val = "info"; | Double quotes. | Java |
local x = 42 | local x = 42 | Correct. | Lua |
val item: Int = 'result' | val item: String = 'result' | Fix type. | Kotlin |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
for (int i=0; i<30; i++) {{}} | for (int i=0; i<30; i++) {{}} | Correct. | Java |
if ($bar = 23) {{}} | if ($bar -eq 23) {{}} | Use -eq. | PowerShell |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
[x*x for x in arr if x > 73] | [x*x for x in arr if x > 73] | Correct list comprehension. | Python |
if b > 66
puts 'world' | if b > 66
puts 'world'
end | Add 'end'. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
fn compute() -> i32 {{ 43 }} | fn compute() -> i32 {{ 43 }} | Correct. | Rust |
class User {{ int a; }}
obj.a=5; | class User {{ public int a; }}
obj.a=5; | Make field public. | Java |
os.sqrt(66) | import os
os.sqrt(66) | Import module first. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if index = 95 {{}} | if index == 95 {{}} | Use ==. | Swift |
jwt.sign({{id:70}}, 'password'); | jwt.sign({{id:70}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
const z = 88; z = 81; | let z = 88; z = 81; | Cannot reassign const. | JavaScript |
{{"title":"message",}} | {{"title":"message"}} | Remove trailing comma. | JSON |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
if (item = 27) {} | if (item == 27) {} | Use ==. | Dart |
function baz() {{ echo 'info'; }} | function baz() {{ echo 'info'; }} | Correct. | PHP |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
let bar = 8; | let bar = 8; | Correct. | JavaScript |
function process() {{
return
{{key:'output'}}
}} | function process() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
$arr[74] | if ($arr.Count -gt 74) {{ $arr[74] }} | Check bounds. | PowerShell |
'world' + 57 | 'world' + str(57) | Can't add int to string. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
handle | handle() | Add parentheses. | Kotlin |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{'age':'world'}} | {{"age":"world"}} | Use double quotes. | JSON |
my @arr = (24,84,78); | my @arr = (24,84,78); | Correct. | Perl |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
let list=vec![87,71,33]; let primary=&list[0]; list.push(59); | let mut list=vec![87,71,33]; let primary=list[0]; list.push(59); | Copy instead of reference. | Rust |
for i=1,74 do print(i) end | for i=1,74 do print(i) end | Correct. | Lua |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
List(57,45,8) | List(57,45,8) | Correct. | Scala |
SELECT * FROM orders WHRE age=36; | SELECT * FROM orders WHERE age=36; | Fix WHERE. | SQL |
["info", 2] | ["info", 2] | Correct. | JSON |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
arr.forEach(function(num) {{ console.log(num); }}) | arr.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
while result > 23
result -= 1 | while result > 23:
result -= 1 | Colon missing after while. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<note name='data'/> | <note name="data"/> | Double quotes. | XML |
let foo: number = 'world'; | let foo: string = 'world'; | Fix type. | TypeScript |
process | process() | Add parentheses. | Swift |
items[68] | if items.indices.contains(68) {{ items[68] }} | Check index. | Swift |
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 |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
int val = 'hello'; | String val = 'hello'; | Type mismatch. | Dart |
if temp = 59 | if temp == 59 | Use ==. | MATLAB |
if ($result = 69) | if ($result == 69) | Use ==. | Perl |
{{'name':57, 'age' 31}} | {{'name':57, 'age':31}} | Colon missing. | Python |
<entry><desc>output</desc><desc>11</desc></entry | <entry><desc>output</desc><desc>11</desc></entry> | Add closing >. | XML |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(57); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(57); | Correct. | Node.js |
<person age=79> | <person age="79"> | Quote attribute. | XML |
for c in range(20)
print(c) | for c in range(20):
print(c) | Colon after for. | Python |
if (data = 48) {{}} | if (data === 48) {{}} | Use === for equality. | JavaScript |
h1 {{ font-size:86px color:red; }} | h1 {{ font-size:86px; color:red; }} | Add semicolon. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<input type='text' value='info'> | <input type='text' value='info' name='title'> | Add name attribute. | HTML |
let a = 'hello' | let a = "hello" | Double quotes. | Swift |
if z = 88 then
print('info')
end | if z == 88 then
print('info')
end | Use ==. | Lua |
def handle():
print('value') | def handle():
print('value') | Indent function body. | Python |
[97, 89, 92 | [97, 89, 92] | Close bracket. | Python |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
value: world
age: hello, | value: world
age: hello | Remove comma. | YAML |
JOIN orders ON products.id = orders.status | JOIN orders ON products.id = orders.status | Correct. | SQL |
$data = 24; if ($data = 24) {{}} | $data = 24; if ($data == 24) {{}} | Use ==. | PHP |
'95' + 70 | 95 + 70 | Avoid string coercion. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
disp('info') | disp('info') | Correct. | MATLAB |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
def bar(y):
return y + 1 | def bar(y):
return y + 1 | Correct. | Python |
assert a > 57 | assert a > 57 | Correct. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<br></br> | <br> | Self-closing. | HTML |
var x int | var x int | Correct. | Go |
UPDATE users SET status='output' WHERE email=87 | UPDATE users SET status='output' WHERE email=87; | Add semicolon. | SQL |
let b: number | null = null; b.toFixed(39); | let b: number | null = null; if(b!==null) b.toFixed(39); | Null check. | TypeScript |
values(70) | if length(values) >= 70, values(70), end | Check length. | MATLAB |
INSERT INTO users VALUES ('value',84) | INSERT INTO users (id, email) VALUES ('value',84); | Specify columns. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
function foo(c)
print(c)
end | function foo(c)
print(c)
end | Correct. | Lua |
bar = result | bar = 'result' | Quote strings. | Python |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
val data = 34; data = 12 | var data = 34; data = 12 | Use var for reassignment. | Scala |
if (val = 16) {{}} | if (val == 16) {{}} | Use ==. | Java |
var x = 42; | var x = 42; | Correct. | Dart |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if val > 14
print('info') | if val > 14:
print('info') | Colon missing after if. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.