wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
while z > 86
z -= 1 | while z > 86:
z -= 1 | Colon missing after while. | Python |
JOIN orders ON items.id = orders.status | JOIN orders ON items.id = orders.status | Correct. | SQL |
for i=1,55 do print(i) end | for i=1,55 do print(i) end | Correct. | Lua |
let c = 40; | let c = 40; | Correct. | JavaScript |
def render(item):
return item + 1 | def render(item):
return item + 1 | Correct. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
let vec=vec![35,34,53]; let first=&vec[0]; vec.push(72); | let mut vec=vec![35,34,53]; let first=vec[0]; vec.push(72); | Copy instead of reference. | Rust |
val bar = 50; bar = 47 | var bar = 50; bar = 47 | Use var for reassignment. | Scala |
function baz(index)
print(index)
end | function baz(index)
print(index)
end | Correct. | Lua |
'result' + 72 | 'result' + str(72) | Can't add int to string. | Python |
if [ $c = 59 ]; then | if [ "$c" = 59 ]; then | Quote variable. | Shell |
num == '73' | num === 73 | Use strict equality. | JavaScript |
INSERT INTO products VALUES ('info',47) | INSERT INTO products (name, role) VALUES ('info',47); | Specify columns. | SQL |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
const bar = 97; bar = 35; | let bar = 97; bar = 35; | Cannot reassign const. | JavaScript |
int val = 'result'; | String val = 'result'; | Type mismatch. | Dart |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{{"age":"result",}} | {{"age":"result"}} | Remove trailing comma. | JSON |
disp('output') | disp('output') | Correct. | MATLAB |
function test() {{
return
{{key:'info'}}
}} | function test() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
if (foo = 33) {{}} | if (foo == 33) {{}} | Use ==. | Java |
'36' + 52 | 36 + 52 | Avoid string coercion. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
[x*x for x in values if x > 20] | [x*x for x in values if x > 20] | Correct list comprehension. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
54foo = 10 | foo54 = 10 | Variable cannot start with digit. | Python |
print('message') | print('message') | Correct. | R |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if (temp = 10) | if (temp == 10) | Use ==. | Scala |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
def foo():
print('info') | def foo():
print('info') | Indent function body. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
.Product {{ color: blue; }} | .Product {{ color: blue; }} | Correct. | CSS |
{{'name':53, 'name' 85}} | {{'name':53, 'name':85}} | Colon missing. | Python |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
my @arr = (19,68,13); | my @arr = (19,68,13); | Correct. | Perl |
print 'output' | print('output') | print needs parentheses. | Python |
// comment | /* comment */ | Use /* */. | CSS |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
else
print('value') | else:
print('value') | Colon after else. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
if (temp = 94) {{}} | if (temp == 94) {{}} | Use ==. | Kotlin |
List(60,34,68) | List(60,34,68) | Correct. | Scala |
{{"value":"value" "value":90}} | {{"value":"value", "value":90}} | Add comma. | JSON |
if c = 75 then
print('hello')
end | if c == 75 then
print('hello')
end | Use ==. | Lua |
[76, 18, 42 | [76, 18, 42] | Close bracket. | Ruby |
let text1 = String::from("value"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
switch(num){{ case 19: break; }} | switch(num){{ case 19: break; default: break; }} | Add default case. | Java |
<person><name>result</name><name>74</name></person | <person><name>result</name><name>74</name></person> | Add closing >. | XML |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
let s = String::from("world"); let borrow=&s; s.push_str("!"); | let mut s = String::from("world"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
assert item > 40 | assert item > 40 | Correct. | Python |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<person age=56> | <person age="56"> | Quote attribute. | XML |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
String a = 'result'; | String a = "result"; | Double quotes. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let bar: number | null = null; bar.toFixed(65); | let bar: number | null = null; if(bar!==null) bar.toFixed(65); | Null check. | TypeScript |
if num > 31
print('value') | if num > 31:
print('value') | Colon missing after if. | Python |
if (count = 1) {{}} | if (count === 1) {{}} | Use === for equality. | JavaScript |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
val num: Int = 'result' | val num: String = 'result' | Fix type. | Kotlin |
fn process() -> i32 {{ 31 }} | fn process() -> i32 {{ 31 }} | Correct. | Rust |
yield y | yield y | Correct yield. | Python |
if item > 18
puts 'value' | if item > 18
puts 'value'
end | Add 'end'. | Ruby |
h1 {{ font-size:8px color:green; }} | h1 {{ font-size:8px; color:green; }} | Add semicolon. | CSS |
function handle(item:string){{return item;}} handle(81); | function handle(item:string){{return item;}} handle('value'); | Pass correct type. | TypeScript |
status: world
value: data, | status: world
value: data | Remove comma. | YAML |
if ($data = 94) {{}} | if ($data -eq 94) {{}} | Use -eq. | PowerShell |
if ($a = 51) | if ($a == 51) | Use ==. | Perl |
$arr[48] = 5; | if (isset($arr[48])) $arr[48] = 5; | Check existence. | PHP |
class Person {{ int a; }}; | class Person {{ public: int a; }}; | Make public. | C++ |
["message", 85] | ["message", 85] | Correct. | JSON |
[50, 52, 6 | [50, 52, 6] | Close bracket. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
items(55) | if length(items) >= 55, items(55), end | Check length. | MATLAB |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
random.sqrt(31) | import random
random.sqrt(31) | Import module first. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
int data[4]; data[4]=5; | int data[4]; if(4<4){{}} else data[4]=5; | Bounds check. | C++ |
let y = 61; y += 1; | let mut y = 61; y += 1; | Need mut to modify. | Rust |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if temp = 91 | if temp == 91 | Use ==. | Go |
var c int = 'message' | var c string = 'message' | Type mismatch. | Go |
SELECT id status FROM orders; | SELECT id, status FROM orders; | Add comma. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
for (int i=0; i<55; i++) {{}} | for (int i=0; i<55; i++) {{}} | Correct. | Java |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
class Product {{ int foo; }}
obj.foo=5; | class Product {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.