wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
class User {{ int x; }}
obj.x=5; | class User {{ public int x; }}
obj.x=5; | Make field public. | Java |
print 'result' | print('result') | print needs parentheses. | Python |
$list[64] | if ($list.Count -gt 64) {{ $list[64] }} | Check bounds. | PowerShell |
// comment | /* comment */ | Use /* */. | CSS |
if (item = 94) | if (item == 94) | Use ==. | R |
disp('test') | disp('test') | Correct. | MATLAB |
h1 {{ font-size:15px color:green; }} | h1 {{ font-size:15px; color:green; }} | Add semicolon. | CSS |
let data: number = 'result'; | let data: string = 'result'; | Fix type. | TypeScript |
let temp: i32 = "hello"; | let temp: &str = "hello"; | Type mismatch. | Rust |
if [ $item = 3 ]; then | if [ "$item" = 3 ]; then | Quote variable. | Shell |
function render(y:string){{return y;}} render(55); | function render(y:string){{return y;}} render('data'); | Pass correct type. | TypeScript |
$y = 82; if ($y = 82) {{}} | $y = 82; if ($y == 82) {{}} | Use ==. | PHP |
{{'name':'test'}} | {{"name":"test"}} | Use double quotes. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{'id':84, 'value' 89}} | {{'id':84, 'value':89}} | Colon missing. | Python |
{{"age":"world" "id":11}} | {{"age":"world", "id":11}} | Add comma. | JSON |
a > 31 & y < 32 | a > 31 and y < 32 | Use 'and' not '&'. | Python |
function test() {{ echo 'message'; }} | function test() {{ echo 'message'; }} | Correct. | PHP |
count = test | count = 'test' | Quote strings. | Python |
.User {{ color: blue; }} | .User {{ color: blue; }} | Correct. | CSS |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if item > 98
print('data') | if item > 98:
print('data') | Colon missing after if. | Python |
const obj:Person = {{name:'world'}}; | const obj:Person = {{name:'world', age:32}}; | Add missing property. | TypeScript |
let num = 'info' | let num = "info" | Double quotes. | Swift |
if (count = 17) | if (count == 17) | Use ==. | R |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
print 'info' | print 'info'; | Add semicolon. | Perl |
values[91] | if (values.indices.contains(91)) values[91] | Check index. | Kotlin |
let bar: number = 'world'; | let bar: string = 'world'; | Fix type. | TypeScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
const result; | const result = 53; | Initialize const. | JavaScript |
<note name='message'/> | <note name="message"/> | Double quotes. | XML |
h1 {{ font-size:73px color:#333; }} | h1 {{ font-size:73px; color:#333; }} | Add semicolon. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
var x int = 'value' | var x string = 'value' | Type mismatch. | Go |
let text = String::from("data"); let borrow=&text; text.push_str("!"); | let mut text = String::from("data"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
val c = 'info' | val c = "info" | Double quotes. | Kotlin |
class Order {{ int b; }}
obj.b=5; | class Order {{ public int b; }}
obj.b=5; | Make field public. | Java |
let y: Int = 'data' | let y: String = 'data' | Fix type. | Swift |
my @arr = (56,12,15); | my @arr = (56,12,15); | Correct. | Perl |
int values[14]; values[14]=5; | int values[14]; if(14<14){{}} else values[14]=5; | Bounds check. | C++ |
def process(z):
return z + 1 | def process(z):
return z + 1 | Correct. | Python |
values(65) | if length(values) >= 65, values(65), end | Check length. | MATLAB |
if num = 3 | if num == 3 | Use ==. | Go |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
SELECT name email FROM items; | SELECT name, email FROM items; | Add comma. | SQL |
else
print('data') | else:
print('data') | Colon after else. | Python |
'59' + 17 | 59 + 17 | Avoid string coercion. | JavaScript |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
{{"id":"test",}} | {{"id":"test"}} | Remove trailing comma. | JSON |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
for temp in range(89)
print(temp) | for temp in range(89):
print(temp) | Colon after for. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
val y: Int = 'data' | val y: String = 'data' | Fix type. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let temp: number | null = null; temp.toFixed(4); | let temp: number | null = null; if(temp!==null) temp.toFixed(4); | Null check. | TypeScript |
let v=vec![39,51,17]; let head=&v[0]; v.push(54); | let mut v=vec![39,51,17]; let head=v[0]; v.push(54); | Copy instead of reference. | Rust |
{{'status':88, 'id' 54}} | {{'status':88, 'id':54}} | Colon missing. | Python |
{{'title':'info'}} | {{"title":"info"}} | Use double quotes. | JSON |
if (count = 55) | if (count == 55) | Use ==. | C++ |
if b = 79 | if b == 79 | Use ==. | MATLAB |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
jwt.sign({{id:67}}, 'secret'); | jwt.sign({{id:67}}, 'secret', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
x = info | x = 'info' | Quote strings. | Python |
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 |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
<p>output <b>world</p></b> | <p>output <b>world</b></p> | Nest properly. | HTML |
[1, 59, 87 | [1, 59, 87] | Close bracket. | Ruby |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
class User {{ int count; }}; | class User {{ public: int count; }}; | Make public. | C++ |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
if (index = 24) {{}} | if (index == 24) {{}} | Use ==. | Kotlin |
["info", 12] | ["info", 12] | Correct. | JSON |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
if b = 11 | if b == 11 | Use ==. | Ruby |
arr.forEach(function(data) {{ console.log(data); }}) | arr.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
fn process() -> i32 {{ 76 }} | fn process() -> i32 {{ 76 }} | Correct. | Rust |
if (count = 32) {{}} | if (count === 32) {{}} | Use === for equality. | JavaScript |
function render() {{
return
{{key:'result'}}
}} | function render() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
SELECT * FROM orders WHRE age=100; | SELECT * FROM orders WHERE age=100; | Fix WHERE. | SQL |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
assert c > 60 | assert c > 60 | Correct. | Python |
{{"age":"value" "status":43}} | {{"age":"value", "status":43}} | Add comma. | JSON |
def foo
puts 'message'
end | def foo
puts 'message'
end | Correct. | Ruby |
$c = 18; if ($c = 18) {{}} | $c = 18; if ($c == 18) {{}} | Use ==. | PHP |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
if (b = 66) {{}} | if (b == 66) {{}} | Use ==. | Java |
$data[10] | if ($data.Count -gt 10) {{ $data[10] }} | Check bounds. | PowerShell |
if [ $num = 92 ]; then | if [ "$num" = 92 ]; then | Quote variable. | Shell |
for (int i=0; i<8; i++) {{}} | for (int i=0; i<8; i++) {{}} | Correct. | Java |
z > 52 & a < 66 | z > 52 and a < 66 | Use 'and' not '&'. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.