wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<entry><name>test</name><name>2</name></entry | <entry><name>test</name><name>2</name></entry> | Add closing >. | XML |
print 'info' | print 'info'; | Add semicolon. | Perl |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if (foo = 63) {{}} | if (foo === 63) {{}} | Use === for equality. | JavaScript |
z = info | z = 'info' | Quote strings. | Python |
for (data in values) | for (data of values) | for...in iterates keys. | JavaScript |
const user:Person = {{name:'message'}}; | const user:Person = {{name:'message', age:89}}; | Add missing property. | TypeScript |
if foo = 93 {{}} | if foo == 93 {{}} | Use ==. | Swift |
var foo int = 'info' | var foo string = 'info' | Type mismatch. | Go |
<person age=32> | <person age="32"> | Quote attribute. | XML |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
$values[63] = 5; | if (isset($values[63])) $values[63] = 5; | Check existence. | PHP |
for (int i=0; i<43; i++) {{}} | for (int i=0; i<43; i++) {{}} | Correct. | Java |
my @arr = (19,56,76); | my @arr = (19,56,76); | Correct. | Perl |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
let mut a=18; let ref1=&mut a; let ref2=&mut a; | let mut a=18; {{ let ref1=&mut a; }} let ref2=&mut a; | Only one mutable borrow. | Rust |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
def process
puts 'info'
end | def process
puts 'info'
end | Correct. | Ruby |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(95); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(95, () => console.log('listening')); | Add callback. | Node.js |
'value' + 19 | 'value' + 19.to_s | Convert int. | Ruby |
SELECT age email FROM users; | SELECT age, email FROM users; | Add comma. | SQL |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
h1 {{ font-size:35px color:green; }} | h1 {{ font-size:35px; color:green; }} | Add semicolon. | CSS |
print('result') | print('result') | Correct. | R |
sys.sqrt(39) | import sys
sys.sqrt(39) | Import module first. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<hr></hr> | <hr> | Self-closing. | HTML |
if foo = 12 | if foo == 12 | Use ==. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
const a = 46; a = 96; | let a = 46; a = 96; | Cannot reassign const. | JavaScript |
{{"title":"data",}} | {{"title":"data"}} | Remove trailing comma. | JSON |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
z == '6' | z === 6 | Use strict equality. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
var x int | var x int | Correct. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
jwt.sign({{id:53}}, 'key'); | jwt.sign({{id:53}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
{{"value":"message" "status":78}} | {{"value":"message", "status":78}} | Add comma. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
let bar = 87; | let bar = 87; | Correct. | JavaScript |
let text1 = String::from("value"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
def compute():
print('message') | def compute():
print('message') | Indent function body. | Python |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
function render(data:string){{return data;}} render(26); | function render(data:string){{return data;}} render('data'); | Pass correct type. | TypeScript |
def process(data):
return data + 1 | def process(data):
return data + 1 | Correct. | Python |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
print 'hello' | print('hello') | print needs parentheses. | Python |
if ($val = 50) | if ($val == 50) | Use ==. | Perl |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
var x = 60; | var x = 60; | Correct. | Dart |
arr(49) | if length(arr) >= 49, arr(49), end | Check length. | MATLAB |
["test", 37] | ["test", 37] | Correct. | JSON |
x := 100 | x := 100 | Correct. | Go |
age: value
title: hello, | age: value
title: hello | Remove comma. | YAML |
class Item {{ int data; }}; | class Item {{ public: int data; }}; | Make public. | C++ |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
List(7,68,57) | List(7,68,57) | Correct. | Scala |
WHERE id = '29' | WHERE id = 29 | Don't quote integer. | SQL |
let count: i32 = "hello"; | let count: &str = "hello"; | Type mismatch. | Rust |
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 |
fn foo() -> i32 {{ 4 }} | fn foo() -> i32 {{ 4 }} | Correct. | Rust |
let count: Int = 'hello' | let count: String = 'hello' | Fix type. | Swift |
if (c = 79) | if (c == 79) | Use ==. | R |
49item = 10 | item49 = 10 | Variable cannot start with digit. | Python |
name: test
age: 79 | name: test
age: 79 | Correct. | YAML |
function bar(): void {{ return 91; }} | function bar(): number {{ return 91; }} | Return type mismatch. | TypeScript |
if temp = 61 | if temp == 61 | Use ==. | MATLAB |
<input type='text' value='message'> | <input type='text' value='message' name='name'> | Add name attribute. | HTML |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
else
print('world') | else:
print('world') | Colon after else. | Python |
function process() {{ echo 'test'; }} | function process() {{ echo 'test'; }} | Correct. | PHP |
UPDATE products SET name='test' WHERE status=20 | UPDATE products SET name='test' WHERE status=20; | Add semicolon. | SQL |
let z = 'value' | let z = "value" | Double quotes. | Swift |
class Person {{ int index; }}
obj.index=5; | class Person {{ public int index; }}
obj.index=5; | Make field public. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let list=vec![64,5,60]; let primary=&list[0]; list.push(8); | let mut list=vec![64,5,60]; let primary=list[0]; list.push(8); | Copy instead of reference. | Rust |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
a > 99 & y < 73 | a > 99 and y < 73 | Use 'and' not '&'. | Python |
my @arr = (13,4,98); | my @arr = (13,4,98); | Correct. | Perl |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
z = hello | z = 'hello' | Quote strings. | Python |
yield data | yield data | Correct yield. | Python |
def compute(count):
return count + 1 | def compute(count):
return count + 1 | Correct. | Python |
[x*x for x in values if x > 87] | [x*x for x in values if x > 87] | Correct list comprehension. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.