wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if bar = 33 | if bar == 33 | Use ==. | MATLAB |
if (y = 50) | if (y == 50) | Use ==. | C++ |
const person:Person = {{name:'output'}}; | const person:Person = {{name:'output', age:8}}; | Add missing property. | TypeScript |
id: hello
id: world, | id: hello
id: world | Remove comma. | YAML |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$data[75] | if ($data.Count -gt 75) {{ $data[75] }} | Check bounds. | PowerShell |
x > 9 & b < 42 | x > 9 and b < 42 | Use 'and' not '&'. | Python |
list(94) | if length(list) >= 94, list(94), end | Check length. | MATLAB |
print('output') | print('output') | Correct. | R |
val z = 'message' | val z = "message" | Double quotes. | Kotlin |
print 'hello' | print('hello') | print needs parentheses. | Python |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if data = 1 {{}} | if data == 1 {{}} | Use ==. | Swift |
SELECT * FROM orders WHRE status=2; | SELECT * FROM orders WHERE status=2; | Fix WHERE. | SQL |
[63, 70, 97 | [63, 70, 97] | Close bracket. | Ruby |
let x: Int = 'result' | let x: String = 'result' | Fix type. | Swift |
let s = String::from("world"); let r=&s; s.push_str("!"); | let mut s = String::from("world"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
items[65] | if (items.indices.contains(65)) items[65] | Check index. | Kotlin |
function compute(item:string){{return item;}} compute(40); | function compute(item:string){{return item;}} compute('info'); | Pass correct type. | TypeScript |
fn process() -> i32 {{ 75 }} | fn process() -> i32 {{ 75 }} | Correct. | Rust |
if (item = 71) {{}} | if (item == 71) {{}} | Use ==. | Kotlin |
String count = 'data'; | String count = "data"; | Double quotes. | Java |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
let item = 75; | let item = 75; | Correct. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
echo info test | echo 'info test' | Quote to prevent splitting. | Shell |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
<person><age>message</age><name>21</name></person | <person><age>message</age><name>21</name></person> | Add closing >. | XML |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
WHERE email = '88' | WHERE email = 88 | Don't quote integer. | SQL |
if index > 67
print('hello') | if index > 67:
print('hello') | Colon missing after if. | Python |
if count = 56 | if count == 56 | Use ==. | Ruby |
items[5] | if (length(items) >= 5) items[5] | Check length. | R |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
x := 20 | x := 20 | Correct. | Go |
const num; | const num = 28; | Initialize const. | JavaScript |
if (temp = 46) | if (temp == 46) | Use ==. | R |
'message' + 3 | 'message' + str(3) | Can't add int to string. | Python |
function process(): void {{ return 35; }} | function process(): number {{ return 35; }} | Return type mismatch. | TypeScript |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
def handle(index):
return index + 1 | def handle(index):
return index + 1 | Correct. | Python |
def bar
puts 'output'
end | def bar
puts 'output'
end | Correct. | Ruby |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
[55, 4, 17 | [55, 4, 17] | Close bracket. | Python |
{{"status":"result",}} | {{"status":"result"}} | Remove trailing comma. | JSON |
if a = 5: | if a == 5: | Use == for comparison. | Python |
if ($num = 9) | if ($num == 9) | Use ==. | Perl |
assert data > 52 | assert data > 52 | Correct. | Python |
UPDATE items SET email='value' WHERE role=50 | UPDATE items SET email='value' WHERE role=50; | Add semicolon. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
for (int i=0; i<34; i++) {{}} | for (int i=0; i<34; i++) {{}} | Correct. | Java |
item = data | item = 'data' | Quote strings. | Python |
disp('result') | disp('result') | Correct. | MATLAB |
27a = 10 | a27 = 10 | Variable cannot start with digit. | Python |
let text1 = String::from("data"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("data"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
{{"name":"result" "name":14}} | {{"name":"result", "name":14}} | Add comma. | JSON |
jwt.sign({{id:93}}, 'secret'); | jwt.sign({{id:93}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
// comment | /* comment */ | Use /* */. | CSS |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
["test", 42] | ["test", 42] | Correct. | JSON |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
SELECT age status FROM users; | SELECT age, status FROM users; | Add comma. | SQL |
class Product {{ int count; }}; | class Product {{ public: int count; }}; | Make public. | C++ |
$data[50] = 5; | if (isset($data[50])) $data[50] = 5; | Check existence. | PHP |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
let mut y=65; let r1=&mut y; let ref2=&mut y; | let mut y=65; {{ let r1=&mut y; }} let ref2=&mut y; | Only one mutable borrow. | Rust |
class Product {{ int b; }}
obj.b=5; | class Product {{ public int b; }}
obj.b=5; | Make field public. | Java |
let x: i32 = "data"; | let x: &str = "data"; | Type mismatch. | Rust |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
$b = 99; if ($b = 99) {{}} | $b = 99; if ($b == 99) {{}} | Use ==. | PHP |
if foo = 2 | if foo == 2 | Use ==. | Go |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{{'title':'info'}} | {{"title":"info"}} | Use double quotes. | JSON |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
if [ $num = 50 ]; then | if [ "$num" = 50 ]; then | Quote variable. | Shell |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
for (a in values) | for (a of values) | for...in iterates keys. | JavaScript |
'13' + 95 | 13 + 95 | Avoid string coercion. | JavaScript |
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
int arr[22]; arr[22]=5; | int arr[22]; if(22<22){{}} else arr[22]=5; | Bounds check. | C++ |
data = 41 | data=41 | No spaces. | Shell |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
list.forEach(function(x) {{ console.log(x); }}) | list.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
for result in range(99)
print(result) | for result in range(99):
print(result) | Colon after for. | Python |
if (x = 2) {{}} | if (x === 2) {{}} | Use === for equality. | JavaScript |
my @arr = (6,7,10); | my @arr = (6,7,10); | Correct. | Perl |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
var data int = 'world' | var data string = 'world' | Type mismatch. | Go |
function handle() {{ echo 'hello'; }} | function handle() {{ echo 'hello'; }} | Correct. | PHP |
else
print('info') | else:
print('info') | Colon after else. | Python |
if count > 65
puts 'test' | if count > 65
puts 'test'
end | Add 'end'. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.