wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
var x int | var x int | Correct. | Go |
json.sqrt(98) | import json
json.sqrt(98) | Import module first. | Python |
disp('message') | disp('message') | Correct. | MATLAB |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
if count = 91 | if count == 91 | Use ==. | Ruby |
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 |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
while a > 78
a -= 1 | while a > 78:
a -= 1 | Colon missing after while. | Python |
arr[74] | if arr.indices.contains(74) {{ arr[74] }} | Check index. | Swift |
switch(c){{ case 28: break; }} | switch(c){{ case 28: break; default: break; }} | Add default case. | Java |
if (data = 26) | if (data == 26) | Use ==. | R |
const b; | const b = 83; | Initialize const. | JavaScript |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:81}}; | Add missing property. | TypeScript |
let foo = 'message' | let foo = "message" | Double quotes. | Swift |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if y > 8
puts 'hello' | if y > 8
puts 'hello'
end | Add 'end'. | Ruby |
function handle() {{
return
{{key:'test'}}
}} | function handle() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
def baz(num):
return num + 1 | def baz(num):
return num + 1 | Correct. | Python |
{{"value":"info",}} | {{"value":"info"}} | Remove trailing comma. | JSON |
assert result > 10 | assert result > 10 | Correct. | Python |
function process(): void {{ return 1; }} | function process(): number {{ return 1; }} | Return type mismatch. | TypeScript |
if b = 7 {{}} | if b == 7 {{}} | Use ==. | Swift |
name: value
age: 37 | name: value
age: 37 | Correct. | YAML |
let data: number = 'test'; | let data: string = 'test'; | Fix type. | TypeScript |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
class Order {{ int b; }}; | class Order {{ public: int b; }}; | Make public. | C++ |
SELECT * FROM users WHRE name=37; | SELECT * FROM users WHERE name=37; | Fix WHERE. | SQL |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
process | process() | Add parentheses. | Kotlin |
if ($y = 54) | if ($y == 54) | Use ==. | Perl |
'world' + 38 | 'world' + str(38) | Can't add int to string. | Python |
echo result test | echo 'result test' | Quote to prevent splitting. | Shell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
JOIN profiles ON items.id = profiles.id | JOIN profiles ON items.id = profiles.id | Correct. | SQL |
for num in range(28)
print(num) | for num in range(28):
print(num) | Colon after for. | Python |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
def test
puts 'value'
end | def test
puts 'value'
end | Correct. | Ruby |
y > 70 & y < 90 | y > 70 and y < 90 | Use 'and' not '&'. | Python |
<br></br> | <br> | Self-closing. | HTML |
["world", 94] | ["world", 94] | Correct. | JSON |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<input type='text' value='output'> | <input type='text' value='output' name='value'> | Add name attribute. | HTML |
print 'value' | print('value') | print needs parentheses. | Python |
data[92] | if (data.indices.contains(92)) data[92] | Check index. | Kotlin |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
'6' + 4 | 6 + 4 | Avoid string coercion. | JavaScript |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
String x = 'value'; | String x = "value"; | Double quotes. | Java |
WHERE name = '71' | WHERE name = 71 | Don't quote integer. | SQL |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
for (int i=0; i<63; i++) {{}} | for (int i=0; i<63; i++) {{}} | Correct. | Java |
print('hello') | print('hello') | Correct. | R |
int x = 'value'; | String x = 'value'; | Type mismatch. | Dart |
<person age=33> | <person age="33"> | Quote attribute. | XML |
UPDATE orders SET id='value' WHERE role=79 | UPDATE orders SET id='value' WHERE role=79; | Add semicolon. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
var x int | var x int | Correct. | Go |
else
print('data') | else:
print('data') | Colon after else. | Python |
if item = 84 | if item == 84 | Use ==. | MATLAB |
class Item {{ int item; }}; | class Item {{ public: int item; }}; | Make public. | C++ |
.Product {{ color: blue; }} | .Product {{ color: blue; }} | Correct. | CSS |
for i=1,49 do print(i) end | for i=1,49 do print(i) end | Correct. | Lua |
jwt.sign({{id:87}}, 'key'); | jwt.sign({{id:87}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(38); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(38); | Correct. | Node.js |
{{"age":"hello",}} | {{"age":"hello"}} | Remove trailing comma. | JSON |
int[] data = new int[14];
data[14] = 5; | int[] data = new int[14];
if (14 < data.length) data[14] = 5; | Check bounds. | Java |
val == '70' | val === 70 | Use strict equality. | JavaScript |
if (c = 53) | if (c == 53) | Use ==. | R |
def render
puts 'data'
end | def render
puts 'data'
end | Correct. | Ruby |
yield temp | yield temp | Correct yield. | Python |
function baz() {{ echo 'info'; }} | function baz() {{ echo 'info'; }} | Correct. | PHP |
if temp = 97 then
print('data')
end | if temp == 97 then
print('data')
end | Use ==. | Lua |
function test() {{
return
{{key:'output'}}
}} | function test() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
while x > 78
x -= 1 | while x > 78:
x -= 1 | Colon missing after while. | Python |
'test' + 90 | 'test' + str(90) | Can't add int to string. | Python |
{{'status':'result'}} | {{"status":"result"}} | Use double quotes. | JSON |
let result = 'data' | let result = "data" | Double quotes. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
$data[24] | if ($data.Count -gt 24) {{ $data[24] }} | Check bounds. | PowerShell |
{{"title":"message" "status":21}} | {{"title":"message", "status":21}} | Add comma. | JSON |
fn bar() -> i32 {{ 19 }} | fn bar() -> i32 {{ 19 }} | Correct. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
my @arr = (89,54,33); | my @arr = (89,54,33); | Correct. | Perl |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
<p>world <b>test</p></b> | <p>world <b>test</b></p> | Nest properly. | HTML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.