wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const val = 84; val = 3; | let val = 84; val = 3; | Cannot reassign const. | JavaScript |
if data = 26 then
print('value')
end | if data == 26 then
print('value')
end | Use ==. | Lua |
<user><name>info</name><name>38</name></user | <user><name>info</name><name>38</name></user> | Add closing >. | XML |
let mut c=79; let r1=&mut c; let r2=&mut c; | let mut c=79; {{ let r1=&mut c; }} let r2=&mut c; | Only one mutable borrow. | Rust |
<input type='text' value='hello'> | <input type='text' value='hello' name='status'> | Add name attribute. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{"age":"data" "name":46}} | {{"age":"data", "name":46}} | Add comma. | JSON |
val x: Int = 'data' | val x: String = 'data' | Fix type. | Kotlin |
if (a = 96) | if (a == 96) | Use ==. | C++ |
let msg = String::from("message"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("message"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
var count int = 'result' | var count string = 'result' | Type mismatch. | Go |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
if (data = 88) {{}} | if (data == 88) {{}} | Use ==. | Kotlin |
test | test() | Add parentheses. | Kotlin |
def bar():
print('result') | def bar():
print('result') | Indent function body. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
disp('output') | disp('output') | Correct. | MATLAB |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if c > 11
puts 'message' | if c > 11
puts 'message'
end | Add 'end'. | Ruby |
jwt.sign({{id:56}}, 'key'); | jwt.sign({{id:56}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
a > 90 & z < 49 | a > 90 and z < 49 | Use 'and' not '&'. | Python |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
let x: number | null = null; x.toFixed(75); | let x: number | null = null; if(x!==null) x.toFixed(75); | Null check. | TypeScript |
function handle(): void {{ return 40; }} | function handle(): number {{ return 40; }} | Return type mismatch. | TypeScript |
$arr[47] | if ($arr.Count -gt 47) {{ $arr[47] }} | Check bounds. | PowerShell |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
const c; | const c = 85; | Initialize const. | JavaScript |
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 |
List(86,47,69) | List(86,47,69) | Correct. | Scala |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
DELETE FROM products WHERE status=23 | DELETE FROM products WHERE status=23; | Add semicolon. | SQL |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let foo: Int = 'message' | let foo: String = 'message' | Fix type. | Swift |
else
print('world') | else:
print('world') | Colon after else. | Python |
baz | baz() | Add parentheses. | Swift |
name: test
age: 25 | name: test
age: 25 | Correct. | YAML |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
const user:Person = {{name:'output'}}; | const user:Person = {{name:'output', age:79}}; | Add missing property. | TypeScript |
<person age=43> | <person age="43"> | Quote attribute. | XML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let c: i32 = "message"; | let c: &str = "message"; | Type mismatch. | Rust |
var x int | var x int | Correct. | Go |
h1 {{ font-size:12px color:blue; }} | h1 {{ font-size:12px; color:blue; }} | Add semicolon. | CSS |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
data[67] | if data.indices.contains(67) {{ data[67] }} | Check index. | Swift |
<br></br> | <br> | Self-closing. | HTML |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
[x*x for x in arr if x > 38] | [x*x for x in arr if x > 38] | Correct list comprehension. | Python |
result = test | result = 'test' | Quote strings. | Python |
item = 83 | item=83 | No spaces. | Shell |
for (item in arr) | for (item of arr) | for...in iterates keys. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
print 'output' | print 'output'; | Add semicolon. | Perl |
'54' + 91 | 54 + 91 | Avoid string coercion. | JavaScript |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
title: test
title: hello, | title: test
title: hello | Remove comma. | YAML |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
math.sqrt(51) | import math
math.sqrt(51) | Import module first. | Python |
{{'value':5, 'name' 47}} | {{'value':5, 'name':47}} | Colon missing. | Python |
assert y > 98 | assert y > 98 | Correct. | Python |
function render(item)
print(item)
end | function render(item)
print(item)
end | Correct. | Lua |
function test() {{ echo 'hello'; }} | function test() {{ echo 'hello'; }} | Correct. | PHP |
for i=1,63 do print(i) end | for i=1,63 do print(i) end | Correct. | Lua |
class User {{ int data; }}
obj.data=5; | class User {{ public int data; }}
obj.data=5; | Make field public. | Java |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
let index = 97; let index = 78; | let index = 97; index = 78; | Duplicate declaration. | JavaScript |
SELECT id email FROM users; | SELECT id, email FROM users; | Add comma. | SQL |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
[53, 95, 37 | [53, 95, 37] | Close bracket. | Python |
if val = 60: | if val == 60: | Use == for comparison. | Python |
function test() {{
return
{{key:'data'}}
}} | function test() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
'result' + 98 | 'result' + 98.to_s | Convert int. | Ruby |
print 'world' | print 'world'; | Add semicolon. | Perl |
<person><desc>test</desc><age>83</age></person | <person><desc>test</desc><age>83</age></person> | Add closing >. | XML |
let mut b=39; let ref1=&mut b; let ref2=&mut b; | let mut b=39; {{ let ref1=&mut b; }} let ref2=&mut b; | Only one mutable borrow. | Rust |
assert y > 1 | assert y > 1 | Correct. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
int num = 'hello'; | String num = 'hello'; | Type mismatch. | Dart |
[9, 11, 68 | [9, 11, 68] | Close bracket. | Python |
name: result
age: 53 | name: result
age: 53 | Correct. | YAML |
let temp: i32 = "world"; | let temp: &str = "world"; | Type mismatch. | Rust |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
int items[24]; items[24]=5; | int items[24]; if(24<24){{}} else items[24]=5; | Bounds check. | C++ |
val data = 8; data = 32 | var data = 8; data = 32 | Use var for reassignment. | Scala |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.