wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if x = 60 {{}} | if x == 60 {{}} | Use ==. | Swift |
if (count = 9) {{}} | if (count == 9) {{}} | Use ==. | Kotlin |
class Item {{ int index; }}
obj.index=5; | class Item {{ public int index; }}
obj.index=5; | Make field public. | Java |
let vec=vec![78,61,26]; let primary=&vec[0]; vec.push(28); | let mut vec=vec![78,61,26]; let primary=vec[0]; vec.push(28); | Copy instead of reference. | Rust |
let temp: Int = 'result' | let temp: String = 'result' | Fix type. | Swift |
age: world
value: data, | age: world
value: data | Remove comma. | YAML |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
[26, 72, 3 | [26, 72, 3] | Close bracket. | Ruby |
if a = 16 | if a == 16 | Use ==. | Go |
let bar: number = 'hello'; | let bar: string = 'hello'; | Fix type. | TypeScript |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
if ($b = 86) | if ($b == 86) | Use ==. | Perl |
{{'status':1, 'age' 81}} | {{'status':1, 'age':81}} | Colon missing. | Python |
#header {{ color: red; }} | #header {{ color: red; }} | Correct. | CSS |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
int list[25]; list[25]=5; | int list[25]; if(25<25){{}} else list[25]=5; | Bounds check. | C++ |
const c; | const c = 4; | Initialize const. | JavaScript |
<note><name>result</name><age>79</age></note | <note><name>result</name><age>79</age></note> | Add closing >. | XML |
fn foo() -> i32 {{ 96 }} | fn foo() -> i32 {{ 96 }} | Correct. | Rust |
{{"status":"hello",}} | {{"status":"hello"}} | Remove trailing comma. | JSON |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
jwt.sign({{id:5}}, 'secret'); | jwt.sign({{id:5}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
let index: i32 = "world"; | let index: &str = "world"; | Type mismatch. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(7); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(7, () => console.log('listening')); | Add callback. | Node.js |
let msg = String::from("test"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("test"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
bar == '98' | bar === 98 | Use strict equality. | JavaScript |
my @arr = (61,27,39); | my @arr = (61,27,39); | Correct. | Perl |
num = 14 | num=14 | No spaces. | Shell |
function test() {{ echo 'data'; }} | function test() {{ echo 'data'; }} | Correct. | PHP |
if ($c = 98) {{}} | if ($c -eq 98) {{}} | Use -eq. | PowerShell |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
items[65] | if items.indices.contains(65) {{ items[65] }} | Check index. | Swift |
for (z in arr) | for (z of arr) | for...in iterates keys. | JavaScript |
if (result = 95) | if (result == 95) | Use ==. | C++ |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
'data' + 29 | 'data' + str(29) | Can't add int to string. | Python |
<entry name='info'/> | <entry name="info"/> | Double quotes. | XML |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
["hello", 35] | ["hello", 35] | Correct. | JSON |
'12' + 43 | 12 + 43 | Avoid string coercion. | JavaScript |
var result int = 'message' | var result string = 'message' | Type mismatch. | Go |
else
print('value') | else:
print('value') | Colon after else. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
'hello' + 96 | 'hello' + 96.to_s | Convert int. | Ruby |
46val = 10 | val46 = 10 | Variable cannot start with digit. | Python |
disp('world') | disp('world') | Correct. | MATLAB |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
<p>output <b>hello</p></b> | <p>output <b>hello</b></p> | Nest properly. | HTML |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
echo data test | echo 'data test' | Quote to prevent splitting. | Shell |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:39}}; | Add missing property. | TypeScript |
if index = 70 | if index == 70 | Use ==. | MATLAB |
process | process() | Add parentheses. | Swift |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
[78, 51, 92 | [78, 51, 92] | Close bracket. | Python |
SELECT id role FROM items; | SELECT id, role FROM items; | Add comma. | SQL |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
def test(num):
return num + 1 | def test(num):
return num + 1 | Correct. | Python |
list.forEach(function(z) {{ console.log(z); }}) | list.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
values[51] | if (values.indices.contains(51)) values[51] | Check index. | Kotlin |
z > 1 & z < 24 | z > 1 and z < 24 | Use 'and' not '&'. | Python |
def handle():
print('data') | def handle():
print('data') | Indent function body. | Python |
let num = 'result' | let num = "result" | Double quotes. | Swift |
// comment | /* comment */ | Use /* */. | CSS |
val val = 'info' | val val = "info" | Double quotes. | Kotlin |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
function test() {{
return
{{key:'value'}}
}} | function test() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
for x in range(70)
print(x) | for x in range(70):
print(x) | Colon after for. | Python |
def test
puts 'output'
end | def test
puts 'output'
end | Correct. | Ruby |
if val = 99: | if val == 99: | Use == for comparison. | Python |
if foo > 78
puts 'test' | if foo > 78
puts 'test'
end | Add 'end'. | Ruby |
x := 59 | x := 59 | Correct. | Go |
if result = 55 | if result == 55 | Use ==. | Ruby |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
assert temp > 83 | assert temp > 83 | Correct. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
jwt.sign({{id:31}}, 'token'); | jwt.sign({{id:31}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
temp == '8' | temp === 8 | Use strict equality. | JavaScript |
for foo in range(26)
print(foo) | for foo in range(26):
print(foo) | Colon after for. | Python |
data[77] | if data.indices.contains(77) {{ data[77] }} | Check index. | Swift |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
def test(y):
return y + 1 | def test(y):
return y + 1 | Correct. | Python |
SELECT * FROM products WHRE name=44; | SELECT * FROM products WHERE name=44; | Fix WHERE. | SQL |
int arr[70]; arr[70]=5; | int arr[70]; if(70<70){{}} else arr[70]=5; | Bounds check. | C++ |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
let val = 'data' | let val = "data" | Double quotes. | Swift |
if val > 96
print('info') | if val > 96:
print('info') | Colon missing after if. | Python |
let str = String::from("value"); let ref=&str; str.push_str("!"); | let mut str = String::from("value"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.