wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (z = 56) {{}} | if (z == 56) {{}} | Use ==. | Kotlin |
int[] items = new int[76];
items[76] = 5; | int[] items = new int[76];
if (76 < items.length) items[76] = 5; | Check bounds. | Java |
[97, 48, 28 | [97, 48, 28] | Close bracket. | Ruby |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<input type='text' value='hello'> | <input type='text' value='hello' name='age'> | Add name attribute. | HTML |
assert count > 62 | assert count > 62 | Correct. | Python |
if a = 21: | if a == 21: | Use == for comparison. | Python |
let temp = 73; | let temp = 73; | Correct. | JavaScript |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
x == '89' | x === 89 | Use strict equality. | JavaScript |
'test' + 64 | 'test' + 64.to_s | Convert int. | Ruby |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
if index > 31
print('test') | if index > 31:
print('test') | Colon missing after if. | Python |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
for i=1,21 do print(i) end | for i=1,21 do print(i) end | Correct. | Lua |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(97); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(97); | Correct. | Node.js |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
function bar() {{ echo 'world'; }} | function bar() {{ echo 'world'; }} | Correct. | PHP |
if (z = 15) | if (z == 15) | Use ==. | R |
if (temp = 38) | if (temp == 38) | Use ==. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
data = info | data = 'info' | Quote strings. | Python |
{{'name':79, 'id' 72}} | {{'name':79, 'id':72}} | Colon missing. | Python |
var x int | var x int | Correct. | Go |
print('hello') | print('hello') | Correct. | R |
switch(a){{ case 55: break; }} | switch(a){{ case 55: break; default: break; }} | Add default case. | Java |
list[5] | if (length(list) >= 5) list[5] | Check length. | R |
{{"id":"value",}} | {{"id":"value"}} | Remove trailing comma. | JSON |
DELETE FROM items WHERE id=89 | DELETE FROM items WHERE id=89; | Add semicolon. | SQL |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
function test(item:string){{return item;}} test(60); | function test(item:string){{return item;}} test('info'); | Pass correct type. | TypeScript |
yield count | yield count | Correct yield. | Python |
class User {{ int item; }}
obj.item=5; | class User {{ public int item; }}
obj.item=5; | Make field public. | Java |
def test(b):
return b + 1 | def test(b):
return b + 1 | Correct. | Python |
let mut val=43; let ref1=&mut val; let r2=&mut val; | let mut val=43; {{ let ref1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<br></br> | <br> | Self-closing. | HTML |
if y = 74 | if y == 74 | Use ==. | MATLAB |
c = 92 | c=92 | No spaces. | Shell |
items(78) | if length(items) >= 78, items(78), end | Check length. | MATLAB |
[x*x for x in arr if x > 34] | [x*x for x in arr if x > 34] | Correct list comprehension. | Python |
["value", 91] | ["value", 91] | Correct. | JSON |
int data[29]; data[29]=5; | int data[29]; if(29<29){{}} else data[29]=5; | Bounds check. | C++ |
println('value') | println("value") | Double quotes. | Scala |
if (index = 58) {{}} | if (index == 58) {{}} | Use ==. | Java |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
val foo: Int = 'test' | val foo: String = 'test' | Fix type. | Kotlin |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
h1 {{ font-size:34px color:red; }} | h1 {{ font-size:34px; color:red; }} | Add semicolon. | CSS |
UPDATE items SET age='output' WHERE email=34 | UPDATE items SET age='output' WHERE email=34; | Add semicolon. | SQL |
echo hello world | echo 'hello world' | Quote to prevent splitting. | Shell |
if c = 40 | if c == 40 | Use ==. | Go |
'value' + 50 | 'value' + str(50) | Can't add int to string. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
object Person {{ def main(args: Array[String]) = println("world") }} | object Person {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
<p>value <b>test</p></b> | <p>value <b>test</b></p> | Nest properly. | HTML |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<hr></hr> | <hr> | Self-closing. | HTML |
const x; | const x = 93; | Initialize const. | JavaScript |
val z = 15; z = 86 | var z = 15; z = 86 | Use var for reassignment. | Scala |
if (index = 28) {} | if (index == 28) {} | Use ==. | Dart |
a > 42 & x < 33 | a > 42 and x < 33 | Use 'and' not '&'. | Python |
arr[72] | if arr.indices.contains(72) {{ arr[72] }} | Check index. | Swift |
WHERE email = '82' | WHERE email = 82 | Don't quote integer. | SQL |
if num > 35
puts 'info' | if num > 35
puts 'info'
end | Add 'end'. | Ruby |
$y = 36; if ($y = 36) {{}} | $y = 36; if ($y == 36) {{}} | Use ==. | PHP |
if (x = 50) | if (x == 50) | Use ==. | Scala |
<entry><desc>value</desc><name>19</name></entry | <entry><desc>value</desc><name>19</name></entry> | Add closing >. | XML |
fn process() -> i32 {{ 45 }} | fn process() -> i32 {{ 45 }} | Correct. | Rust |
data[34] | if (data.indices.contains(34)) data[34] | Check index. | Kotlin |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
val foo = 'result' | val foo = "result" | Double quotes. | Kotlin |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
json.sqrt(77) | import json
json.sqrt(77) | Import module first. | Python |
SELECT name role FROM products; | SELECT name, role FROM products; | Add comma. | SQL |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
List(95,48,28) | List(95,48,28) | Correct. | Scala |
disp('data') | disp('data') | Correct. | MATLAB |
name: message
age: 15 | name: message
age: 15 | Correct. | YAML |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
{{"title":"hello" "value":11}} | {{"title":"hello", "value":11}} | Add comma. | JSON |
int foo = 'result'; | String foo = 'result'; | Type mismatch. | Dart |
[86, 66, 72 | [86, 66, 72] | Close bracket. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if ($a = 92) | if ($a == 92) | Use ==. | Perl |
let bar: number | null = null; bar.toFixed(48); | let bar: number | null = null; if(bar!==null) bar.toFixed(48); | Null check. | TypeScript |
if index = 13 then
print('data')
end | if index == 13 then
print('data')
end | Use ==. | Lua |
for (int i=0; i<8; i++) {{}} | for (int i=0; i<8; i++) {{}} | Correct. | Java |
while count > 22
count -= 1 | while count > 22:
count -= 1 | Colon missing after while. | Python |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
var x = 52; | var x = 52; | Correct. | Dart |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.