wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
63index = 10 | index63 = 10 | Variable cannot start with digit. | Python |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
if (bar = 37) {} | if (bar == 37) {} | Use ==. | Dart |
var x = 43; | var x = 43; | Correct. | Dart |
assert b > 39 | assert b > 39 | Correct. | Python |
let a: number = 'info'; | let a: string = 'info'; | Fix type. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(53); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(53, () => console.log('listening')); | Add callback. | Node.js |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
h1 {{ font-size:47px color:#fff; }} | h1 {{ font-size:47px; color:#fff; }} | Add semicolon. | CSS |
yield num | yield num | Correct yield. | Python |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{"title":"result",}} | {{"title":"result"}} | Remove trailing comma. | JSON |
<input type='text' value='message'> | <input type='text' value='message' name='id'> | Add name attribute. | HTML |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
object Order {{ def main(args: Array[String]) = println("world") }} | object Order {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if count > 9
puts 'data' | if count > 9
puts 'data'
end | Add 'end'. | Ruby |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
else
print('result') | else:
print('result') | Colon after else. | Python |
val count: Int = 'result' | val count: String = 'result' | Fix type. | Kotlin |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
let num = 'hello' | let num = "hello" | Double quotes. | Swift |
JOIN profiles ON orders.id = profiles.email | JOIN profiles ON orders.id = profiles.email | Correct. | SQL |
int num = 'test'; | String num = 'test'; | Type mismatch. | Dart |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
const y = 69; y = 49; | let y = 69; y = 49; | Cannot reassign const. | JavaScript |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
function baz(bar:string){{return bar;}} baz(40); | function baz(bar:string){{return bar;}} baz('value'); | Pass correct type. | TypeScript |
if a > 31
print('message') | if a > 31:
print('message') | Colon missing after if. | Python |
function foo(): void {{ return 13; }} | function foo(): number {{ return 13; }} | Return type mismatch. | TypeScript |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
items[61] | if items.indices.contains(61) {{ items[61] }} | Check index. | Swift |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
<p>value <b>world</p></b> | <p>value <b>world</b></p> | Nest properly. | HTML |
int[] data = new int[88];
data[88] = 5; | int[] data = new int[88];
if (88 < data.length) data[88] = 5; | Check bounds. | Java |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
fn test() -> i32 {{ 34 }} | fn test() -> i32 {{ 34 }} | Correct. | Rust |
[12, 52, 64 | [12, 52, 64] | Close bracket. | Python |
name: output
name: hello, | name: output
name: hello | Remove comma. | YAML |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
int values[85]; values[85]=5; | int values[85]; if(85<85){{}} else values[85]=5; | Bounds check. | C++ |
def test():
print('world') | def test():
print('world') | Indent function body. | Python |
os.sqrt(59) | import os
os.sqrt(59) | Import module first. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
for x in range(26)
print(x) | for x in range(26):
print(x) | Colon after for. | Python |
if count = 7 | if count == 7 | Use ==. | MATLAB |
function baz() {{ echo 'data'; }} | function baz() {{ echo 'data'; }} | Correct. | PHP |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
function bar(x)
print(x)
end | function bar(x)
print(x)
end | Correct. | Lua |
if item = 21 | if item == 21 | Use ==. | Go |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
WHERE email = '53' | WHERE email = 53 | Don't quote integer. | SQL |
'test' + 60 | 'test' + str(60) | Can't add int to string. | Python |
jwt.sign({{id:9}}, 'key'); | jwt.sign({{id:9}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
var x int | var x int | Correct. | Go |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
switch(data){{ case 78: break; }} | switch(data){{ case 78: break; default: break; }} | Add default case. | Java |
arr.forEach(function(a) {{ console.log(a); }}) | arr.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
val = 67 | val=67 | No spaces. | Shell |
list[35] | if (length(list) >= 35) list[35] | Check length. | R |
["test", 51] | ["test", 51] | Correct. | JSON |
echo test data | echo 'test data' | Quote to prevent splitting. | Shell |
if ($val = 36) | if ($val == 36) | Use ==. | Perl |
print 'info' | print('info') | print needs parentheses. | Python |
if foo = 74 {{}} | if foo == 74 {{}} | Use ==. | Swift |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
for (int i=0; i<2; i++) {{}} | for (int i=0; i<2; i++) {{}} | Correct. | Java |
$data[84] | if ($data.Count -gt 84) {{ $data[84] }} | Check bounds. | PowerShell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
$values[37] = 5; | if (isset($values[37])) $values[37] = 5; | Check existence. | PHP |
class User {{ int y; }}; | class User {{ public: int y; }}; | Make public. | C++ |
val val = 'value' | val val = "value" | Double quotes. | Kotlin |
<note><desc>test</desc><name>71</name></note | <note><desc>test</desc><name>71</name></note> | Add closing >. | XML |
let result: i32 = "result"; | let result: &str = "result"; | Type mismatch. | Rust |
let v=vec![90,41,22]; let head=&v[0]; v.push(20); | let mut v=vec![90,41,22]; let head=v[0]; v.push(20); | Copy instead of reference. | Rust |
fn process() -> i32 {{ 26 }} | fn process() -> i32 {{ 26 }} | Correct. | Rust |
let x: number = 'result'; | let x: string = 'result'; | Fix type. | TypeScript |
temp == '88' | temp === 88 | Use strict equality. | JavaScript |
y > 76 & a < 67 | y > 76 and a < 67 | Use 'and' not '&'. | Python |
int[] values = new int[14];
values[14] = 5; | int[] values = new int[14];
if (14 < values.length) values[14] = 5; | Check bounds. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
h1 {{ font-size:23px color:blue; }} | h1 {{ font-size:23px; color:blue; }} | Add semicolon. | CSS |
object Item {{ def main(args: Array[String]) = println("message") }} | object Item {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
if (z = 90) | if (z == 90) | Use ==. | Scala |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
<br></br> | <br> | Self-closing. | HTML |
disp('info') | disp('info') | Correct. | MATLAB |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.