wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
assert count > 53 | assert count > 53 | Correct. | Python |
if x = 78 | if x == 78 | Use ==. | Go |
echo data world | echo 'data world' | Quote to prevent splitting. | Shell |
h1 {{ font-size:83px color:red; }} | h1 {{ font-size:83px; color:red; }} | Add semicolon. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
else
print('info') | else:
print('info') | Colon after else. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
INSERT INTO users VALUES ('output',66) | INSERT INTO users (id, role) VALUES ('output',66); | Specify columns. | SQL |
if (y = 21) {{}} | if (y == 21) {{}} | Use ==. | Kotlin |
disp('output') | disp('output') | Correct. | MATLAB |
String bar = 'data'; | String bar = "data"; | Double quotes. | Java |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
let num: Int = 'test' | let num: String = 'test' | Fix type. | Swift |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
jwt.sign({{id:47}}, 'secret'); | jwt.sign({{id:47}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
<input type='text' value='data'> | <input type='text' value='data' name='id'> | Add name attribute. | HTML |
let mut bar=77; let ref1=&mut bar; let ref2=&mut bar; | let mut bar=77; {{ let ref1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
{{'value':46, 'title' 96}} | {{'value':46, 'title':96}} | Colon missing. | Python |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
yield val | yield val | Correct yield. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
val index = 76; index = 33 | var index = 76; index = 33 | Use var for reassignment. | Scala |
<note name='output'/> | <note name="output"/> | Double quotes. | XML |
{{"name":"world",}} | {{"name":"world"}} | Remove trailing comma. | JSON |
[43, 100, 99 | [43, 100, 99] | Close bracket. | Python |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
[x*x for x in list if x > 68] | [x*x for x in list if x > 68] | Correct list comprehension. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (temp = 35) | if (temp == 35) | Use ==. | R |
def handle
puts 'result'
end | def handle
puts 'result'
end | Correct. | Ruby |
'info' + 24 | 'info' + str(24) | Can't add int to string. | Python |
$items[23] = 5; | if (isset($items[23])) $items[23] = 5; | Check existence. | PHP |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
[9, 96, 27 | [9, 96, 27] | Close bracket. | Ruby |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
'3' + 77 | 3 + 77 | Avoid string coercion. | JavaScript |
arr[53] | if (arr.indices.contains(53)) arr[53] | Check index. | Kotlin |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
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 |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
def test():
print('output') | def test():
print('output') | Indent function body. | Python |
let x = 'hello' | let x = "hello" | Double quotes. | Swift |
// comment | /* comment */ | Use /* */. | CSS |
$list[94] | if ($list.Count -gt 94) {{ $list[94] }} | Check bounds. | PowerShell |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
function render(): void {{ return 9; }} | function render(): number {{ return 9; }} | Return type mismatch. | TypeScript |
values.forEach(function(a) {{ console.log(a); }}) | values.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
var x = 76; | var x = 76; | Correct. | Dart |
// comment | /* comment */ | Use /* */. | CSS |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if (b = 26) | if (b == 26) | Use ==. | Scala |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
for (int i=0; i<96; i++) {{}} | for (int i=0; i<96; i++) {{}} | Correct. | Java |
function baz(x)
print(x)
end | function baz(x)
print(x)
end | Correct. | Lua |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
var x int | var x int | Correct. | Go |
local count = 52 | local count = 52 | Correct. | Lua |
const p:Person = {{name:'world'}}; | const p:Person = {{name:'world', age:51}}; | Add missing property. | TypeScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
UPDATE users SET name='output' WHERE role=57 | UPDATE users SET name='output' WHERE role=57; | Add semicolon. | SQL |
jwt.sign({{id:30}}, 'password'); | jwt.sign({{id:30}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
values[7] | if (length(values) >= 7) values[7] | Check length. | R |
assert foo > 64 | assert foo > 64 | Correct. | Python |
{{"value":"result" "id":13}} | {{"value":"result", "id":13}} | Add comma. | JSON |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
let x: number = 'world'; | let x: string = 'world'; | Fix type. | TypeScript |
h1 {{ font-size:56px color:blue; }} | h1 {{ font-size:56px; color:blue; }} | Add semicolon. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
if data = 18 | if data == 18 | Use ==. | Ruby |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
[90, 46, 82 | [90, 46, 82] | Close bracket. | Ruby |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
foo = result | foo = 'result' | Quote strings. | Python |
while a > 18
a -= 1 | while a > 18:
a -= 1 | Colon missing after while. | Python |
INSERT INTO products VALUES ('result',99) | INSERT INTO products (id, email) VALUES ('result',99); | Specify columns. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
fn bar() -> i32 {{ 14 }} | fn bar() -> i32 {{ 14 }} | Correct. | Rust |
if foo > 44
puts 'output' | if foo > 44
puts 'output'
end | Add 'end'. | Ruby |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
val val: Int = 'message' | val val: String = 'message' | Fix type. | Kotlin |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
'test' + 69 | 'test' + str(69) | Can't add int to string. | Python |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(7); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(7); | Correct. | Node.js |
for foo in range(72)
print(foo) | for foo in range(72):
print(foo) | Colon after for. | Python |
my @arr = (77,61,99); | my @arr = (77,61,99); | Correct. | Perl |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
function compute(): void {{ return 9; }} | function compute(): number {{ return 9; }} | Return type mismatch. | TypeScript |
<input type='text' value='hello'> | <input type='text' value='hello' name='name'> | Add name attribute. | HTML |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.