wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$arr[96] = 5; | if (isset($arr[96])) $arr[96] = 5; | Check existence. | PHP |
for i=1,66 do print(i) end | for i=1,66 do print(i) end | Correct. | Lua |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
const obj:Person = {{name:'message'}}; | const obj:Person = {{name:'message', age:15}}; | Add missing property. | TypeScript |
function foo(a:string){{return a;}} foo(62); | function foo(a:string){{return a;}} foo('info'); | Pass correct type. | TypeScript |
def handle():
print('test') | def handle():
print('test') | Indent function body. | Python |
h1 {{ font-size:73px color:green; }} | h1 {{ font-size:73px; color:green; }} | Add semicolon. | CSS |
print('result') | print('result') | Correct. | R |
let str = String::from("test"); let borrow=&str; str.push_str("!"); | let mut str = String::from("test"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (x = 12) | if (x == 12) | Use ==. | C++ |
if (item = 36) {{}} | if (item == 36) {{}} | Use ==. | Java |
function handle() {{
return
{{key:'output'}}
}} | function handle() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
<p>result <b>test</p></b> | <p>result <b>test</b></p> | Nest properly. | HTML |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
["test", 34] | ["test", 34] | Correct. | JSON |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
class Item {{ int bar; }}
obj.bar=5; | class Item {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
let x = 22; | let x = 22; | Correct. | JavaScript |
if num = 23 | if num == 23 | Use ==. | Ruby |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
String val = 'value'; | String val = "value"; | Double quotes. | Java |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
if (b = 89) | if (b == 89) | Use ==. | Scala |
def test
puts 'message'
end | def test
puts 'message'
end | Correct. | Ruby |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
<entry name='result'/> | <entry name="result"/> | Double quotes. | XML |
b = test | b = 'test' | Quote strings. | Python |
assert foo > 1 | assert foo > 1 | Correct. | Python |
UPDATE items SET age='value' WHERE role=88 | UPDATE items SET age='value' WHERE role=88; | Add semicolon. | SQL |
'output' + 21 | 'output' + str(21) | Can't add int to string. | Python |
<person age=37> | <person age="37"> | Quote attribute. | XML |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
[x*x for x in arr if x > 52] | [x*x for x in arr if x > 52] | Correct list comprehension. | Python |
const num; | const num = 11; | Initialize const. | JavaScript |
function render(bar)
print(bar)
end | function render(bar)
print(bar)
end | Correct. | Lua |
function process() {{ echo 'hello'; }} | function process() {{ echo 'hello'; }} | Correct. | PHP |
data == '51' | data === 51 | Use strict equality. | JavaScript |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
val item: Int = 'value' | val item: String = 'value' | Fix type. | Kotlin |
function render(): void {{ return 14; }} | function render(): number {{ return 14; }} | Return type mismatch. | TypeScript |
[43, 17, 92 | [43, 17, 92] | Close bracket. | Ruby |
INSERT INTO items VALUES ('hello',80) | INSERT INTO items (id, status) VALUES ('hello',80); | Specify columns. | SQL |
var x = 14; | var x = 14; | Correct. | Dart |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
print 'value' | print 'value'; | Add semicolon. | Perl |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
$data[24] | if ($data.Count -gt 24) {{ $data[24] }} | Check bounds. | PowerShell |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
jwt.sign({{id:40}}, 'secret'); | jwt.sign({{id:40}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
for (foo in values) | for (foo of values) | for...in iterates keys. | JavaScript |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
values.forEach(function(c) {{ console.log(c); }}) | values.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
def foo(count):
return count + 1 | def foo(count):
return count + 1 | Correct. | Python |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
echo output hello | echo 'output hello' | Quote to prevent splitting. | Shell |
{{'title':8, 'value' 23}} | {{'title':8, 'value':23}} | Colon missing. | Python |
my @arr = (11,45,26); | my @arr = (11,45,26); | Correct. | Perl |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{'status':'result'}} | {{"status":"result"}} | Use double quotes. | JSON |
if ($count = 43) | if ($count == 43) | Use ==. | Perl |
const count = 72; count = 17; | let count = 72; count = 17; | Cannot reassign const. | JavaScript |
list[7] | if (length(list) >= 7) list[7] | Check length. | R |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
for (int i=0; i<40; i++) {{}} | for (int i=0; i<40; i++) {{}} | Correct. | Java |
while b > 84
b -= 1 | while b > 84:
b -= 1 | Colon missing after while. | Python |
fn render() -> i32 {{ 39 }} | fn render() -> i32 {{ 39 }} | Correct. | Rust |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<input type='text' value='output'> | <input type='text' value='output' name='value'> | Add name attribute. | HTML |
re.sqrt(74) | import re
re.sqrt(74) | Import module first. | Python |
let mut x=4; let ref1=&mut x; let ref2=&mut x; | let mut x=4; {{ let ref1=&mut x; }} let ref2=&mut x; | Only one mutable borrow. | Rust |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
let item: i32 = "output"; | let item: &str = "output"; | Type mismatch. | Rust |
[43, 55, 10 | [43, 55, 10] | Close bracket. | Python |
'17' + 87 | 17 + 87 | Avoid string coercion. | JavaScript |
data = 24 | data=24 | No spaces. | Shell |
else
print('value') | else:
print('value') | Colon after else. | Python |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
bar | bar() | Add parentheses. | Swift |
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 |
if item > 90
puts 'value' | if item > 90
puts 'value'
end | Add 'end'. | Ruby |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
if temp = 4 | if temp == 4 | Use ==. | Go |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if b = 85: | if b == 85: | Use == for comparison. | Python |
if (result = 22) {} | if (result == 22) {} | Use ==. | Dart |
local val = 6 | local val = 6 | Correct. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.