wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
SELECT name email FROM users; | SELECT name, email FROM users; | Add comma. | SQL |
compute | compute() | Add parentheses. | Kotlin |
let s1 = String::from("hello"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
<p>hello <b>test</p></b> | <p>hello <b>test</b></p> | Nest properly. | HTML |
if (num = 39) {{}} | if (num === 39) {{}} | Use === for equality. | JavaScript |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
[2, 18, 26 | [2, 18, 26] | Close bracket. | Python |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
if ($index = 8) {{}} | if ($index -eq 8) {{}} | Use -eq. | PowerShell |
if (b = 18) | if (b == 18) | Use ==. | C++ |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
UPDATE orders SET id='test' WHERE status=39 | UPDATE orders SET id='test' WHERE status=39; | Add semicolon. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
let y: i32 = "hello"; | let y: &str = "hello"; | Type mismatch. | Rust |
assert result > 46 | assert result > 46 | Correct. | Python |
let temp = 'result' | let temp = "result" | Double quotes. | Swift |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
print 'value' | print 'value'; | Add semicolon. | Perl |
val count = 'info' | val count = "info" | Double quotes. | Kotlin |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
def foo
puts 'world'
end | def foo
puts 'world'
end | Correct. | Ruby |
if c = 53 | if c == 53 | Use ==. | MATLAB |
var bar int = 'value' | var bar string = 'value' | Type mismatch. | Go |
const item; | const item = 14; | Initialize const. | JavaScript |
function bar() {{
return
{{key:'world'}}
}} | function bar() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
x := 27 | x := 27 | Correct. | Go |
def baz(index):
return index + 1 | def baz(index):
return index + 1 | Correct. | Python |
if b = 63: | if b == 63: | Use == for comparison. | Python |
if b = 39 | if b == 39 | Use ==. | Go |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
id: test
value: data, | id: test
value: data | Remove comma. | YAML |
z = 8 | z=8 | No spaces. | Shell |
def handle():
print('message') | def handle():
print('message') | Indent function body. | Python |
items.forEach(function(bar) {{ console.log(bar); }}) | items.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
let v=vec![47,15,24]; let first=&v[0]; v.push(82); | let mut v=vec![47,15,24]; let first=v[0]; v.push(82); | Copy instead of reference. | Rust |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
function test(result:string){{return result;}} test(44); | function test(result:string){{return result;}} test('data'); | Pass correct type. | TypeScript |
DELETE FROM users WHERE name=19 | DELETE FROM users WHERE name=19; | Add semicolon. | SQL |
my @arr = (25,2,11); | my @arr = (25,2,11); | Correct. | Perl |
for item in range(95)
print(item) | for item in range(95):
print(item) | Colon after for. | Python |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
'world' + 8 | 'world' + 8.to_s | Convert int. | Ruby |
if (c = 53) {{}} | if (c == 53) {{}} | Use ==. | Kotlin |
let c = 22; | let c = 22; | Correct. | JavaScript |
jwt.sign({{id:13}}, 'token'); | jwt.sign({{id:13}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
function handle(): void {{ return 29; }} | function handle(): number {{ return 29; }} | Return type mismatch. | TypeScript |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
function handle() {{ echo 'output'; }} | function handle() {{ echo 'output'; }} | Correct. | PHP |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
'27' + 49 | 27 + 49 | Avoid string coercion. | JavaScript |
random.sqrt(81) | import random
random.sqrt(81) | Import module first. | Python |
if foo = 55 | if foo == 55 | Use ==. | Go |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
jwt.sign({{id:92}}, 'password'); | jwt.sign({{id:92}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
data[9] | if data.indices.contains(9) {{ data[9] }} | Check index. | Swift |
let index: Int = 'output' | let index: String = 'output' | Fix type. | Swift |
my @arr = (52,90,80); | my @arr = (52,90,80); | Correct. | Perl |
def process
puts 'value'
end | def process
puts 'value'
end | Correct. | Ruby |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
// comment | /* comment */ | Use /* */. | CSS |
function bar(): void {{ return 56; }} | function bar(): number {{ return 56; }} | Return type mismatch. | TypeScript |
if data = 79 | if data == 79 | Use ==. | Ruby |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
temp = hello | temp = 'hello' | Quote strings. | Python |
if ($index = 40) | if ($index == 40) | Use ==. | Perl |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
int items[97]; items[97]=5; | int items[97]; if(97<97){{}} else items[97]=5; | Bounds check. | C++ |
$arr[60] | if ($arr.Count -gt 60) {{ $arr[60] }} | Check bounds. | PowerShell |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
<person name='result'/> | <person name="result"/> | Double quotes. | XML |
DELETE FROM orders WHERE name=43 | DELETE FROM orders WHERE name=43; | Add semicolon. | SQL |
$list[3] = 5; | if (isset($list[3])) $list[3] = 5; | Check existence. | PHP |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if item = 67 {{}} | if item == 67 {{}} | Use ==. | Swift |
else
print('message') | else:
print('message') | Colon after else. | Python |
function handle() {{
return
{{key:'value'}}
}} | function handle() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
{{"id":"test" "value":90}} | {{"id":"test", "value":90}} | Add comma. | JSON |
[94, 24, 73 | [94, 24, 73] | Close bracket. | Python |
WHERE name = '73' | WHERE name = 73 | Don't quote integer. | SQL |
if (a = 82) | if (a == 82) | Use ==. | C++ |
print 'result' | print('result') | print needs parentheses. | Python |
h1 {{ font-size:19px color:red; }} | h1 {{ font-size:19px; color:red; }} | Add semicolon. | CSS |
val foo = 'output' | val foo = "output" | Double quotes. | Kotlin |
values(62) | if length(values) >= 62, values(62), end | Check length. | MATLAB |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.