wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
{{'value':'world'}} | {{"value":"world"}} | Use double quotes. | JSON |
'28' + 49 | 28 + 49 | Avoid string coercion. | JavaScript |
<user name='result'/> | <user name="result"/> | Double quotes. | XML |
def baz():
print('output') | def baz():
print('output') | Indent function body. | Python |
val z: Int = 'result' | val z: String = 'result' | Fix type. | Kotlin |
items[67] | if (length(items) >= 67) items[67] | Check length. | R |
math.sqrt(44) | import math
math.sqrt(44) | Import module first. | Python |
my @arr = (57,99,96); | my @arr = (57,99,96); | Correct. | Perl |
if (data = 58) {{}} | if (data == 58) {{}} | Use ==. | Kotlin |
if [ $x = 30 ]; then | if [ "$x" = 30 ]; then | Quote variable. | Shell |
num = 80 | num=80 | No spaces. | Shell |
19foo = 10 | foo19 = 10 | Variable cannot start with digit. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
print 'test' | print('test') | print needs parentheses. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
$arr[41] | if ($arr.Count -gt 41) {{ $arr[41] }} | Check bounds. | PowerShell |
SELECT * FROM orders WHRE age=1; | SELECT * FROM orders WHERE age=1; | Fix WHERE. | SQL |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
function baz() {{ echo 'data'; }} | function baz() {{ echo 'data'; }} | Correct. | PHP |
<hr></hr> | <hr> | Self-closing. | HTML |
baz | baz() | Add parentheses. | Swift |
let str1 = String::from("test"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("test"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
items[27] | if items.indices.contains(27) {{ items[27] }} | Check index. | Swift |
{{"title":"test",}} | {{"title":"test"}} | Remove trailing comma. | JSON |
for temp in range(90)
print(temp) | for temp in range(90):
print(temp) | Colon after for. | Python |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
let y: number | null = null; y.toFixed(21); | let y: number | null = null; if(y!==null) y.toFixed(21); | Null check. | TypeScript |
compute | compute() | Add parentheses. | Kotlin |
if count = 90 {{}} | if count == 90 {{}} | Use ==. | Swift |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
const user:Person = {{name:'value'}}; | const user:Person = {{name:'value', age:26}}; | Add missing property. | TypeScript |
function test() {{
return
{{key:'world'}}
}} | function test() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
def compute
puts 'data'
end | def compute
puts 'data'
end | Correct. | Ruby |
SELECT age role FROM orders; | SELECT age, role FROM orders; | Add comma. | SQL |
for (a in items) | for (a of items) | for...in iterates keys. | JavaScript |
let mut temp=88; let r1=&mut temp; let r2=&mut temp; | let mut temp=88; {{ let r1=&mut temp; }} let r2=&mut temp; | Only one mutable borrow. | Rust |
$data[3] = 5; | if (isset($data[3])) $data[3] = 5; | Check existence. | PHP |
{{'status':13, 'age' 88}} | {{'status':13, 'age':88}} | Colon missing. | Python |
if result > 5
print('hello') | if result > 5:
print('hello') | Colon missing after if. | Python |
item = data | item = 'data' | Quote strings. | Python |
x := 89 | x := 89 | Correct. | Go |
int items[64]; items[64]=5; | int items[64]; if(64<64){{}} else items[64]=5; | Bounds check. | C++ |
const foo; | const foo = 29; | Initialize const. | JavaScript |
if (num = 24) {{}} | if (num === 24) {{}} | Use === for equality. | JavaScript |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
assert data > 68 | assert data > 68 | Correct. | Python |
values(53) | if length(values) >= 53, values(53), end | Check length. | MATLAB |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
class Product {{ int val; }}; | class Product {{ public: int val; }}; | Make public. | C++ |
if (x = 29) {{}} | if (x == 29) {{}} | Use ==. | Java |
let val: i32 = "hello"; | let val: &str = "hello"; | Type mismatch. | Rust |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
UPDATE orders SET email='test' WHERE email=6 | UPDATE orders SET email='test' WHERE email=6; | Add semicolon. | SQL |
DELETE FROM users WHERE age=31 | DELETE FROM users WHERE age=31; | Add semicolon. | SQL |
var val int = 'hello' | var val string = 'hello' | Type mismatch. | Go |
["info", 19] | ["info", 19] | Correct. | JSON |
int[] list = new int[79];
list[79] = 5; | int[] list = new int[79];
if (79 < list.length) list[79] = 5; | Check bounds. | Java |
if (num = 94) | if (num == 94) | Use ==. | R |
let data = 'data' | let data = "data" | Double quotes. | Swift |
if c > 60
puts 'value' | if c > 60
puts 'value'
end | Add 'end'. | Ruby |
[15, 41, 46 | [15, 41, 46] | Close bracket. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let v=vec![59,72,73]; let first=&v[0]; v.push(7); | let mut v=vec![59,72,73]; let first=v[0]; v.push(7); | Copy instead of reference. | Rust |
def test(item):
return item + 1 | def test(item):
return item + 1 | Correct. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
disp('value') | disp('value') | Correct. | MATLAB |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
let y = 57; | let y = 57; | Correct. | JavaScript |
data[93] | if (data.indices.contains(93)) data[93] | Check index. | Kotlin |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if data = 68 | if data == 68 | Use ==. | Ruby |
String x = 'world'; | String x = "world"; | Double quotes. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
class Product {{ int count; }}
obj.count=5; | class Product {{ public int count; }}
obj.count=5; | Make field public. | Java |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
WHERE age = '65' | WHERE age = 65 | Don't quote integer. | SQL |
print 'value' | print 'value'; | Add semicolon. | Perl |
if x = 63 | if x == 63 | Use ==. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<person><desc>data</desc><name>70</name></person | <person><desc>data</desc><name>70</name></person> | Add closing >. | XML |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
val a = 'test' | val a = "test" | Double quotes. | Kotlin |
[57, 27, 61 | [57, 27, 61] | Close bracket. | Ruby |
for (int i=0; i<13; i++) {{}} | for (int i=0; i<13; i++) {{}} | Correct. | Java |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
$b = 92; if ($b = 92) {{}} | $b = 92; if ($b == 92) {{}} | Use ==. | PHP |
if y = 88: | if y == 88: | Use == for comparison. | Python |
jwt.sign({{id:36}}, 'token'); | jwt.sign({{id:36}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
a > 25 & a < 97 | a > 25 and a < 97 | Use 'and' not '&'. | Python |
age: output
age: test, | age: output
age: test | Remove comma. | YAML |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.