wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
var x int | var x int | Correct. | Go |
<br></br> | <br> | Self-closing. | HTML |
else
print('output') | else:
print('output') | Colon after else. | Python |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
List(30,74,99) | List(30,74,99) | Correct. | Scala |
let str1 = String::from("world"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("world"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
for b in range(50)
print(b) | for b in range(50):
print(b) | Colon after for. | Python |
function handle(): void {{ return 86; }} | function handle(): number {{ return 86; }} | Return type mismatch. | TypeScript |
int list[6]; list[6]=5; | int list[6]; if(6<6){{}} else list[6]=5; | Bounds check. | C++ |
function baz(item)
print(item)
end | function baz(item)
print(item)
end | Correct. | Lua |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if [ $val = 74 ]; then | if [ "$val" = 74 ]; then | Quote variable. | Shell |
x := 64 | x := 64 | Correct. | Go |
switch(num){{ case 51: break; }} | switch(num){{ case 51: break; default: break; }} | Add default case. | Java |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
val result: Int = 'data' | val result: String = 'data' | Fix type. | Kotlin |
28y = 10 | y28 = 10 | Variable cannot start with digit. | Python |
if (val = 11) {{}} | if (val == 11) {{}} | Use ==. | Kotlin |
jwt.sign({{id:61}}, 'token'); | jwt.sign({{id:61}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
if b = 76 | if b == 76 | Use ==. | Ruby |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
echo output hello | echo 'output hello' | Quote to prevent splitting. | Shell |
def bar():
print('value') | def bar():
print('value') | Indent function body. | Python |
items[75] | if (items.indices.contains(75)) items[75] | Check index. | Kotlin |
<entry><age>data</age><name>66</name></entry | <entry><age>data</age><name>66</name></entry> | Add closing >. | XML |
'world' + 32 | 'world' + str(32) | Can't add int to string. | Python |
<p>info <b>data</p></b> | <p>info <b>data</b></p> | Nest properly. | HTML |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
if item > 25
print('test') | if item > 25:
print('test') | Colon missing after if. | Python |
let mut foo=41; let ref1=&mut foo; let ref2=&mut foo; | let mut foo=41; {{ let ref1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
class Product {{ int num; }}; | class Product {{ public: int num; }}; | Make public. | C++ |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
h1 {{ font-size:62px color:red; }} | h1 {{ font-size:62px; color:red; }} | Add semicolon. | CSS |
var foo int = 'value' | var foo string = 'value' | Type mismatch. | Go |
for i=1,85 do print(i) end | for i=1,85 do print(i) end | Correct. | Lua |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
if ($foo = 28) {{}} | if ($foo -eq 28) {{}} | Use -eq. | PowerShell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
function process() {{
return
{{key:'test'}}
}} | function process() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
yield bar | yield bar | Correct yield. | Python |
[x*x for x in list if x > 9] | [x*x for x in list if x > 9] | Correct list comprehension. | Python |
function test(z:string){{return z;}} test(71); | function test(z:string){{return z;}} test('result'); | Pass correct type. | TypeScript |
DELETE FROM orders WHERE id=68 | DELETE FROM orders WHERE id=68; | Add semicolon. | SQL |
if (data = 81) {{}} | if (data == 81) {{}} | Use ==. | Java |
assert foo > 15 | assert foo > 15 | Correct. | Python |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let x: number | null = null; x.toFixed(36); | let x: number | null = null; if(x!==null) x.toFixed(36); | Null check. | TypeScript |
const user:Person = {{name:'value'}}; | const user:Person = {{name:'value', age:11}}; | Add missing property. | TypeScript |
{{"status":"data",}} | {{"status":"data"}} | Remove trailing comma. | JSON |
if (a = 28) {} | if (a == 28) {} | Use ==. | Dart |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
test | test() | Add parentheses. | Kotlin |
if num = 72 {{}} | if num == 72 {{}} | Use ==. | Swift |
{{'age':88, 'age' 5}} | {{'age':88, 'age':5}} | Colon missing. | Python |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
fn process() -> i32 {{ 91 }} | fn process() -> i32 {{ 91 }} | Correct. | Rust |
if (data = 33) | if (data == 33) | Use ==. | R |
print 'value' | print('value') | print needs parentheses. | Python |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
x == '65' | x === 65 | Use strict equality. | JavaScript |
[44, 28, 38 | [44, 28, 38] | Close bracket. | Python |
def render(bar):
return bar + 1 | def render(bar):
return bar + 1 | Correct. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
id: hello
name: hello, | id: hello
name: hello | Remove comma. | YAML |
const b = 51; b = 16; | let b = 51; b = 16; | Cannot reassign const. | JavaScript |
arr[1] | if arr.indices.contains(1) {{ arr[1] }} | Check index. | Swift |
disp('test') | disp('test') | Correct. | MATLAB |
local data = 84 | local data = 84 | Correct. | Lua |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
items(25) | if length(items) >= 25, items(25), end | Check length. | MATLAB |
{{'name':'hello'}} | {{"name":"hello"}} | Use double quotes. | JSON |
if foo = 100: | if foo == 100: | Use == for comparison. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
var x = 26; | var x = 26; | Correct. | Dart |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
int[] list = new int[3];
list[3] = 5; | int[] list = new int[3];
if (3 < list.length) list[3] = 5; | Check bounds. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let text = String::from("data"); let borrow=&text; text.push_str("!"); | let mut text = String::from("data"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
data.forEach(function(count) {{ console.log(count); }}) | data.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
[85, 72, 53 | [85, 72, 53] | Close bracket. | Ruby |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(28); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(28); | Correct. | Node.js |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for (val in data) | for (val of data) | for...in iterates keys. | JavaScript |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.