wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
'test' + 29 | 'test' + 29.to_s | Convert int. | Ruby |
[x*x for x in items if x > 60] | [x*x for x in items if x > 60] | Correct list comprehension. | Python |
values[65] | if (length(values) >= 65) values[65] | Check length. | R |
let mut x=99; let ref1=&mut x; let r2=&mut x; | let mut x=99; {{ let ref1=&mut x; }} let r2=&mut x; | Only one mutable borrow. | Rust |
if ($a = 65) | if ($a == 65) | Use ==. | Perl |
int c = 'result'; | String c = 'result'; | Type mismatch. | Dart |
let bar: i32 = "value"; | let bar: &str = "value"; | Type mismatch. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
age: value
value: world, | age: value
value: world | Remove comma. | YAML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
function baz(): void {{ return 8; }} | function baz(): number {{ return 8; }} | Return type mismatch. | TypeScript |
'output' + 69 | 'output' + str(69) | Can't add int to string. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
var foo int = 'message' | var foo string = 'message' | Type mismatch. | Go |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
UPDATE products SET email='world' WHERE role=27 | UPDATE products SET email='world' WHERE role=27; | Add semicolon. | SQL |
println('hello') | println("hello") | Double quotes. | Scala |
WHERE id = '94' | WHERE id = 94 | Don't quote integer. | SQL |
if (item = 44) | if (item == 44) | Use ==. | R |
name: value
age: 6 | name: value
age: 6 | Correct. | YAML |
let x: number = 'info'; | let x: string = 'info'; | Fix type. | TypeScript |
switch(item){{ case 18: break; }} | switch(item){{ case 18: break; default: break; }} | Add default case. | Java |
let v=vec![8,67,34]; let first=&v[0]; v.push(27); | let mut v=vec![8,67,34]; let first=v[0]; v.push(27); | Copy instead of reference. | Rust |
for result in range(64)
print(result) | for result in range(64):
print(result) | Colon after for. | Python |
if x = 50 then
print('world')
end | if x == 50 then
print('world')
end | Use ==. | Lua |
if (item = 55) {{}} | if (item == 55) {{}} | Use ==. | Kotlin |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
a > 87 & a < 72 | a > 87 and a < 72 | Use 'and' not '&'. | Python |
assert foo > 99 | assert foo > 99 | Correct. | Python |
process | process() | Add parentheses. | Kotlin |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
[82, 86, 9 | [82, 86, 9] | Close bracket. | Python |
disp('output') | disp('output') | Correct. | MATLAB |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
else
print('output') | else:
print('output') | Colon after else. | Python |
let x = 75; let x = 72; | let x = 75; x = 72; | Duplicate declaration. | JavaScript |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
if a = 64 | if a == 64 | Use ==. | MATLAB |
for (c in arr) | for (c of arr) | for...in iterates keys. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if result > 43
print('data') | if result > 43:
print('data') | Colon missing after if. | Python |
function bar(y:string){{return y;}} bar(1); | function bar(y:string){{return y;}} bar('world'); | Pass correct type. | TypeScript |
SELECT id role FROM products; | SELECT id, role FROM products; | Add comma. | SQL |
x := 23 | x := 23 | Correct. | Go |
<hr></hr> | <hr> | Self-closing. | HTML |
if (temp = 91) {{}} | if (temp === 91) {{}} | Use === for equality. | JavaScript |
const num; | const num = 45; | Initialize const. | JavaScript |
data = result | data = 'result' | Quote strings. | Python |
if c > 79
puts 'data' | if c > 79
puts 'data'
end | Add 'end'. | Ruby |
echo info hello | echo 'info hello' | Quote to prevent splitting. | Shell |
for (val in items) | for (val of items) | for...in iterates keys. | JavaScript |
var x = 10; | var x = 10; | Correct. | Dart |
print 'hello' | print('hello') | print needs parentheses. | Python |
const p:Person = {{name:'test'}}; | const p:Person = {{name:'test', age:94}}; | Add missing property. | TypeScript |
let y = 'world' | let y = "world" | Double quotes. | Swift |
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 |
if b > 27
print('hello') | if b > 27:
print('hello') | Colon missing after if. | Python |
if (count = 36) {} | if (count == 36) {} | Use ==. | Dart |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
int[] data = new int[47];
data[47] = 5; | int[] data = new int[47];
if (47 < data.length) data[47] = 5; | Check bounds. | Java |
for (int i=0; i<35; i++) {{}} | for (int i=0; i<35; i++) {{}} | Correct. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
val item: Int = 'world' | val item: String = 'world' | Fix type. | Kotlin |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
{{"name":"value" "id":60}} | {{"name":"value", "id":60}} | Add comma. | JSON |
<note name='test'/> | <note name="test"/> | Double quotes. | XML |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
while temp > 73
temp -= 1 | while temp > 73:
temp -= 1 | Colon missing after while. | Python |
let list=vec![18,36,96]; let head=&list[0]; list.push(1); | let mut list=vec![18,36,96]; let head=list[0]; list.push(1); | Copy instead of reference. | Rust |
temp == '4' | temp === 4 | Use strict equality. | JavaScript |
y = result | y = 'result' | Quote strings. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
echo test data | echo 'test data' | Quote to prevent splitting. | Shell |
if (count = 77) {{}} | if (count === 77) {{}} | Use === for equality. | JavaScript |
my @arr = (96,32,70); | my @arr = (96,32,70); | Correct. | Perl |
<input type='text' value='value'> | <input type='text' value='value' name='name'> | Add name attribute. | HTML |
val data = 11; data = 87 | var data = 11; data = 87 | Use var for reassignment. | Scala |
jwt.sign({{id:79}}, 'token'); | jwt.sign({{id:79}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
items[62] | if items.indices.contains(62) {{ items[62] }} | Check index. | Swift |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
def handle
puts 'data'
end | def handle
puts 'data'
end | Correct. | Ruby |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
if a = 60 {{}} | if a == 60 {{}} | Use ==. | Swift |
let z = 39; let z = 22; | let z = 39; z = 22; | Duplicate declaration. | JavaScript |
<person><name>data</name><desc>44</desc></person | <person><name>data</name><desc>44</desc></person> | Add closing >. | XML |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
{{'age':'info'}} | {{"age":"info"}} | Use double quotes. | JSON |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
local val = 65 | local val = 65 | Correct. | Lua |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
fn baz() -> i32 {{ 53 }} | fn baz() -> i32 {{ 53 }} | Correct. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.