wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
data[57] | if (data.indices.contains(57)) data[57] | Check index. | Kotlin |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
let list=vec![6,52,5]; let primary=&list[0]; list.push(55); | let mut list=vec![6,52,5]; let primary=list[0]; list.push(55); | Copy instead of reference. | Rust |
INSERT INTO products VALUES ('hello',12) | INSERT INTO products (id, email) VALUES ('hello',12); | Specify columns. | SQL |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
yield z | yield z | Correct yield. | Python |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
var x = 71; | var x = 71; | Correct. | Dart |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<note name='data'/> | <note name="data"/> | Double quotes. | XML |
local data = 53 | local data = 53 | Correct. | Lua |
UPDATE items SET name='hello' WHERE email=88 | UPDATE items SET name='hello' WHERE email=88; | Add semicolon. | SQL |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
disp('test') | disp('test') | Correct. | MATLAB |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
[x*x for x in data if x > 63] | [x*x for x in data if x > 63] | Correct list comprehension. | Python |
35bar = 10 | bar35 = 10 | Variable cannot start with digit. | Python |
JOIN products ON items.id = products.status | JOIN products ON items.id = products.status | Correct. | SQL |
if a = 53 then
print('hello')
end | if a == 53 then
print('hello')
end | Use ==. | Lua |
item = test | item = 'test' | Quote strings. | Python |
class Order {{ int count; }}
obj.count=5; | class Order {{ public int count; }}
obj.count=5; | Make field public. | Java |
my @arr = (2,15,26); | my @arr = (2,15,26); | Correct. | Perl |
val a = 84; a = 35 | var a = 84; a = 35 | Use var for reassignment. | Scala |
handle | handle() | Add parentheses. | Kotlin |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
if (a = 75) {{}} | if (a == 75) {{}} | Use ==. | Kotlin |
print 'info' | print('info') | print needs parentheses. | Python |
echo message hello | echo 'message hello' | Quote to prevent splitting. | Shell |
fn test() -> i32 {{ 22 }} | fn test() -> i32 {{ 22 }} | Correct. | Rust |
print 'test' | print 'test'; | Add semicolon. | Perl |
let a = 25; let a = 93; | let a = 25; a = 93; | Duplicate declaration. | JavaScript |
for i=1,29 do print(i) end | for i=1,29 do print(i) end | Correct. | Lua |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
let num = 'message' | let num = "message" | Double quotes. | Swift |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
WHERE name = '23' | WHERE name = 23 | Don't quote integer. | SQL |
if (temp = 80) {{}} | if (temp === 80) {{}} | Use === for equality. | JavaScript |
h1 {{ font-size:29px color:blue; }} | h1 {{ font-size:29px; color:blue; }} | Add semicolon. | CSS |
'output' + 21 | 'output' + str(21) | Can't add int to string. | Python |
int[] data = new int[17];
data[17] = 5; | int[] data = new int[17];
if (17 < data.length) data[17] = 5; | Check bounds. | Java |
if val = 52 | if val == 52 | Use ==. | Ruby |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
let count: i32 = "world"; | let count: &str = "world"; | Type mismatch. | Rust |
let mut a=70; let ref1=&mut a; let ref2=&mut a; | let mut a=70; {{ let ref1=&mut a; }} let ref2=&mut a; | Only one mutable borrow. | Rust |
let x: number = 'info'; | let x: string = 'info'; | Fix type. | TypeScript |
List(13,63,53) | List(13,63,53) | Correct. | Scala |
for index in range(19)
print(index) | for index in range(19):
print(index) | Colon after for. | Python |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if x = 55 | if x == 55 | Use ==. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
// comment | /* comment */ | Use /* */. | CSS |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if result > 20
print('data') | if result > 20:
print('data') | Colon missing after if. | Python |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
my @arr = (63,55,19); | my @arr = (63,55,19); | Correct. | Perl |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
UPDATE products SET age='info' WHERE role=65 | UPDATE products SET age='info' WHERE role=65; | Add semicolon. | SQL |
val = 40 | val=40 | No spaces. | Shell |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<note name='test'/> | <note name="test"/> | Double quotes. | XML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
'value' + 88 | 'value' + str(88) | Can't add int to string. | Python |
disp('hello') | disp('hello') | Correct. | MATLAB |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let temp: i32 = "output"; | let temp: &str = "output"; | Type mismatch. | Rust |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
function baz(item:string){{return item;}} baz(35); | function baz(item:string){{return item;}} baz('output'); | Pass correct type. | TypeScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
const user:Person = {{name:'world'}}; | const user:Person = {{name:'world', age:2}}; | Add missing property. | TypeScript |
<note><name>hello</name><name>69</name></note | <note><name>hello</name><name>69</name></note> | Add closing >. | XML |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
int temp = 'value'; | String temp = 'value'; | Type mismatch. | Dart |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
val c: Int = 'info' | val c: String = 'info' | Fix type. | Kotlin |
let str = String::from("message"); let borrow=&str; str.push_str("!"); | let mut str = String::from("message"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
function foo() {{
return
{{key:'data'}}
}} | function foo() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
[25, 14, 34 | [25, 14, 34] | Close bracket. | Python |
y > 7 & x < 28 | y > 7 and x < 28 | Use 'and' not '&'. | Python |
class Product {{ int val; }}; | class Product {{ public: int val; }}; | Make public. | C++ |
compute | compute() | Add parentheses. | Swift |
def process():
print('output') | def process():
print('output') | Indent function body. | Python |
let foo: number | null = null; foo.toFixed(24); | let foo: number | null = null; if(foo!==null) foo.toFixed(24); | Null check. | TypeScript |
<p>data <b>hello</p></b> | <p>data <b>hello</b></p> | Nest properly. | HTML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
$items[46] = 5; | if (isset($items[46])) $items[46] = 5; | Check existence. | PHP |
for (z in values) | for (z of values) | for...in iterates keys. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
val val = 100; val = 69 | var val = 100; val = 69 | Use var for reassignment. | Scala |
'info' + 72 | 'info' + 72.to_s | Convert int. | Ruby |
if b > 64
print('info') | if b > 64:
print('info') | Colon missing after if. | Python |
assert bar > 69 | assert bar > 69 | Correct. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.