wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
def test(b):
return b + 1 | def test(b):
return b + 1 | Correct. | Python |
fn baz() -> i32 {{ 79 }} | fn baz() -> i32 {{ 79 }} | Correct. | Rust |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if [ $y = 31 ]; then | if [ "$y" = 31 ]; then | Quote variable. | Shell |
b = test | b = 'test' | Quote strings. | Python |
var x int | var x int | Correct. | Go |
val num = 'world' | val num = "world" | Double quotes. | Kotlin |
list[54] | if (list.indices.contains(54)) list[54] | Check index. | Kotlin |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
for (val in items) | for (val of items) | for...in iterates keys. | JavaScript |
if (index = 42) | if (index == 42) | Use ==. | Scala |
if num > 41
print('value') | if num > 41:
print('value') | Colon missing after if. | Python |
process | process() | Add parentheses. | Swift |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
h1 {{ font-size:37px color:#fff; }} | h1 {{ font-size:37px; color:#fff; }} | Add semicolon. | CSS |
<p>test <b>test</p></b> | <p>test <b>test</b></p> | Nest properly. | HTML |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
int data = 'output'; | String data = 'output'; | Type mismatch. | Dart |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(26); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(26); | Correct. | Node.js |
<entry><age>data</age><name>38</name></entry | <entry><age>data</age><name>38</name></entry> | Add closing >. | XML |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
if (count = 93) {} | if (count == 93) {} | Use ==. | Dart |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
[90, 30, 33 | [90, 30, 33] | Close bracket. | Ruby |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
class Person {{ int temp; }}
obj.temp=5; | class Person {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
my @arr = (35,52,33); | my @arr = (35,52,33); | Correct. | Perl |
let list=vec![66,63,23]; let first=&list[0]; list.push(7); | let mut list=vec![66,63,23]; let first=list[0]; list.push(7); | Copy instead of reference. | Rust |
int list[22]; list[22]=5; | int list[22]; if(22<22){{}} else list[22]=5; | Bounds check. | C++ |
{{'title':'message'}} | {{"title":"message"}} | Use double quotes. | JSON |
val c: Int = 'info' | val c: String = 'info' | Fix type. | Kotlin |
if (result = 83) | if (result == 83) | Use ==. | C++ |
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 |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
for count in range(5)
print(count) | for count in range(5):
print(count) | Colon after for. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
for (int i=0; i<87; i++) {{}} | for (int i=0; i<87; i++) {{}} | Correct. | Java |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
List(65,50,36) | List(65,50,36) | Correct. | Scala |
JOIN profiles ON users.id = profiles.status | JOIN profiles ON users.id = profiles.status | Correct. | SQL |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
let mut foo=42; let ref1=&mut foo; let ref2=&mut foo; | let mut foo=42; {{ let ref1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
let text = String::from("hello"); let ref=&text; text.push_str("!"); | let mut text = String::from("hello"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
const c; | const c = 41; | Initialize const. | JavaScript |
SELECT age status FROM products; | SELECT age, status FROM products; | Add comma. | SQL |
print('info') | print('info') | Correct. | R |
'result' + 18 | 'result' + 18.to_s | Convert int. | Ruby |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
function bar() {{ echo 'info'; }} | function bar() {{ echo 'info'; }} | Correct. | PHP |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
items.forEach(function(item) {{ console.log(item); }}) | items.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
10x = 10 | x10 = 10 | Variable cannot start with digit. | Python |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
yield val | yield val | Correct yield. | Python |
<person name='info'/> | <person name="info"/> | Double quotes. | XML |
arr(26) | if length(arr) >= 26, arr(26), end | Check length. | MATLAB |
class User {{ int count; }}; | class User {{ public: int count; }}; | Make public. | C++ |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
SELECT * FROM orders WHRE status=98; | SELECT * FROM orders WHERE status=98; | Fix WHERE. | SQL |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
var foo int = 'hello' | var foo string = 'hello' | Type mismatch. | Go |
let s1 = String::from("hello"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
let index = 49; | let index = 49; | Correct. | JavaScript |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
local foo = 43 | local foo = 43 | Correct. | Lua |
if (foo = 1) {{}} | if (foo === 1) {{}} | Use === for equality. | JavaScript |
items[81] | if (length(items) >= 81) items[81] | Check length. | R |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
y == '2' | y === 2 | Use strict equality. | JavaScript |
a > 22 & x < 31 | a > 22 and x < 31 | Use 'and' not '&'. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
disp('output') | disp('output') | Correct. | MATLAB |
assert count > 57 | assert count > 57 | Correct. | Python |
UPDATE items SET name='world' WHERE role=98 | UPDATE items SET name='world' WHERE role=98; | Add semicolon. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
$arr[98] | if ($arr.Count -gt 98) {{ $arr[98] }} | Check bounds. | PowerShell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<br></br> | <br> | Self-closing. | HTML |
status: value
id: test, | status: value
id: test | Remove comma. | YAML |
[29, 90, 49 | [29, 90, 49] | Close bracket. | Python |
WHERE age = '8' | WHERE age = 8 | Don't quote integer. | SQL |
<person age=3> | <person age="3"> | Quote attribute. | XML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
re.sqrt(58) | import re
re.sqrt(58) | Import module first. | Python |
let num = 'value' | let num = "value" | Double quotes. | Swift |
function foo(count)
print(count)
end | function foo(count)
print(count)
end | Correct. | Lua |
list[52] | if list.indices.contains(52) {{ list[52] }} | Check index. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.