wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let bar: Int = 'data' | let bar: String = 'data' | Fix type. | Swift |
if [ $bar = 75 ]; then | if [ "$bar" = 75 ]; then | Quote variable. | Shell |
let a = 86; | let a = 86; | Correct. | JavaScript |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
print 'info' | print('info') | print needs parentheses. | Python |
print('output') | print('output') | Correct. | R |
if data > 57
puts 'info' | if data > 57
puts 'info'
end | Add 'end'. | Ruby |
let msg = String::from("data"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
val num: Int = 'world' | val num: String = 'world' | Fix type. | Kotlin |
while a > 32
a -= 1 | while a > 32:
a -= 1 | Colon missing after while. | Python |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
def compute(z):
return z + 1 | def compute(z):
return z + 1 | Correct. | Python |
if num = 24 {{}} | if num == 24 {{}} | Use ==. | Swift |
<person age=86> | <person age="86"> | Quote attribute. | XML |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
name: result
name: test, | name: result
name: test | Remove comma. | YAML |
{{"value":"message" "id":70}} | {{"value":"message", "id":70}} | Add comma. | JSON |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:37}}; | Add missing property. | TypeScript |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
SELECT * FROM items WHRE email=49; | SELECT * FROM items WHERE email=49; | Fix WHERE. | SQL |
59temp = 10 | temp59 = 10 | Variable cannot start with digit. | Python |
int[] items = new int[22];
items[22] = 5; | int[] items = new int[22];
if (22 < items.length) items[22] = 5; | Check bounds. | Java |
object Product {{ def main(args: Array[String]) = println("output") }} | object Product {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
my @arr = (83,60,52); | my @arr = (83,60,52); | Correct. | Perl |
const data; | const data = 63; | Initialize const. | JavaScript |
let mut x=29; let ref1=&mut x; let r2=&mut x; | let mut x=29; {{ let ref1=&mut x; }} let r2=&mut x; | Only one mutable borrow. | Rust |
else
print('output') | else:
print('output') | Colon after else. | Python |
["data", 20] | ["data", 20] | Correct. | JSON |
class Item {{ int z; }}; | class Item {{ public: int z; }}; | Make public. | C++ |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
let data = 17; data += 1; | let mut data = 17; data += 1; | Need mut to modify. | Rust |
if (item = 48) {{}} | if (item == 48) {{}} | Use ==. | Java |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
<br></br> | <br> | Self-closing. | HTML |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
def process():
print('hello') | def process():
print('hello') | Indent function body. | Python |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
<hr></hr> | <hr> | Self-closing. | HTML |
[x*x for x in data if x > 2] | [x*x for x in data if x > 2] | Correct list comprehension. | Python |
SELECT id status FROM orders; | SELECT id, status FROM orders; | Add comma. | SQL |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
if index = 90: | if index == 90: | Use == for comparison. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(95); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(95, () => console.log('listening')); | Add callback. | Node.js |
x > 22 & a < 70 | x > 22 and a < 70 | Use 'and' not '&'. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<note name='value'/> | <note name="value"/> | Double quotes. | XML |
// comment | /* comment */ | Use /* */. | CSS |
<input type='text' value='result'> | <input type='text' value='result' name='name'> | Add name attribute. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(90); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(90); | Correct. | Node.js |
disp('message') | disp('message') | Correct. | MATLAB |
jwt.sign({{id:32}}, 'token'); | jwt.sign({{id:32}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
if (foo = 22) | if (foo == 22) | Use ==. | R |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
temp = value | temp = 'value' | Quote strings. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let b: number | null = null; b.toFixed(8); | let b: number | null = null; if(b!==null) b.toFixed(8); | Null check. | TypeScript |
if num = 70 | if num == 70 | Use ==. | MATLAB |
UPDATE users SET name='world' WHERE role=3 | UPDATE users SET name='world' WHERE role=3; | Add semicolon. | SQL |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
x == '43' | x === 43 | Use strict equality. | JavaScript |
function baz(): void {{ return 90; }} | function baz(): number {{ return 90; }} | Return type mismatch. | TypeScript |
{{'name':41, 'title' 82}} | {{'name':41, 'title':82}} | Colon missing. | Python |
'44' + 4 | 44 + 4 | Avoid string coercion. | JavaScript |
if y = 57 | if y == 57 | Use ==. | Go |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
for result in range(45)
print(result) | for result in range(45):
print(result) | Colon after for. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
x := 85 | x := 85 | Correct. | Go |
WHERE status = '84' | WHERE status = 84 | Don't quote integer. | SQL |
assert y > 15 | assert y > 15 | Correct. | Python |
list[71] | if list.indices.contains(71) {{ list[71] }} | Check index. | Swift |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
if (num = 56) {} | if (num == 56) {} | Use ==. | Dart |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<entry><name>message</name><age>44</age></entry | <entry><name>message</name><age>44</age></entry> | Add closing >. | XML |
name: test
age: 95 | name: test
age: 95 | Correct. | YAML |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
data.forEach(function(data) {{ console.log(data); }}) | data.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
[43, 11, 95 | [43, 11, 95] | Close bracket. | Python |
function compute() {{
return
{{key:'test'}}
}} | function compute() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
yield foo | yield foo | Correct yield. | Python |
if (c = 85) {{}} | if (c === 85) {{}} | Use === for equality. | JavaScript |
for (c in values) | for (c of values) | for...in iterates keys. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.