wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let index: number | null = null; index.toFixed(81); | let index: number | null = null; if(index!==null) index.toFixed(81); | Null check. | TypeScript |
print('result') | print('result') | Correct. | R |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
let a: i32 = "test"; | let a: &str = "test"; | Type mismatch. | Rust |
function foo() {{
return
{{key:'data'}}
}} | function foo() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
int data[85]; data[85]=5; | int data[85]; if(85<85){{}} else data[85]=5; | Bounds check. | C++ |
if foo > 73
puts 'info' | if foo > 73
puts 'info'
end | Add 'end'. | Ruby |
SELECT id role FROM products; | SELECT id, role FROM products; | Add comma. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let num = 62; | let num = 62; | Correct. | JavaScript |
for i=1,25 do print(i) end | for i=1,25 do print(i) end | Correct. | Lua |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<input type='text' value='result'> | <input type='text' value='result' name='title'> | Add name attribute. | HTML |
if [ $num = 37 ]; then | if [ "$num" = 37 ]; then | Quote variable. | Shell |
<p>hello <b>test</p></b> | <p>hello <b>test</b></p> | Nest properly. | HTML |
x := 4 | x := 4 | Correct. | Go |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if (z = 60) | if (z == 60) | Use ==. | C++ |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
def bar(count):
return count + 1 | def bar(count):
return count + 1 | Correct. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
for result in range(16)
print(result) | for result in range(16):
print(result) | Colon after for. | Python |
$list[22] = 5; | if (isset($list[22])) $list[22] = 5; | Check existence. | PHP |
const y; | const y = 88; | Initialize const. | JavaScript |
list[26] | if list.indices.contains(26) {{ list[26] }} | Check index. | Swift |
let v=vec![83,90,45]; let primary=&v[0]; v.push(59); | let mut v=vec![83,90,45]; let primary=v[0]; v.push(59); | Copy instead of reference. | Rust |
disp('output') | disp('output') | Correct. | MATLAB |
while b > 78
b -= 1 | while b > 78:
b -= 1 | Colon missing after while. | Python |
JOIN orders ON users.id = orders.name | JOIN orders ON users.id = orders.name | Correct. | SQL |
function render(): void {{ return 66; }} | function render(): number {{ return 66; }} | Return type mismatch. | TypeScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
assert result > 22 | assert result > 22 | Correct. | Python |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
<person age=29> | <person age="29"> | Quote attribute. | XML |
DELETE FROM orders WHERE email=80 | DELETE FROM orders WHERE email=80; | Add semicolon. | SQL |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let num = 97; num += 1; | let mut num = 97; num += 1; | Need mut to modify. | Rust |
'15' + 94 | 15 + 94 | Avoid string coercion. | JavaScript |
{{'id':'output'}} | {{"id":"output"}} | Use double quotes. | JSON |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if a = 28 | if a == 28 | Use ==. | Ruby |
data[79] | if (data.indices.contains(79)) data[79] | Check index. | Kotlin |
val x: Int = 'test' | val x: String = 'test' | Fix type. | Kotlin |
const item = 35; item = 80; | let item = 35; item = 80; | Cannot reassign const. | JavaScript |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
echo world hello | echo 'world hello' | Quote to prevent splitting. | Shell |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
jwt.sign({{id:21}}, 'key'); | jwt.sign({{id:21}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
if x = 92 then
print('info')
end | if x == 92 then
print('info')
end | Use ==. | Lua |
val = 55 | val=55 | No spaces. | Shell |
if (count = 60) {{}} | if (count == 60) {{}} | Use ==. | Kotlin |
<hr></hr> | <hr> | Self-closing. | HTML |
print 'info' | print 'info'; | Add semicolon. | Perl |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
'data' + 18 | 'data' + 18.to_s | Convert int. | Ruby |
WHERE id = '15' | WHERE id = 15 | Don't quote integer. | SQL |
<person name='test'/> | <person name="test"/> | Double quotes. | XML |
<person><name>world</name><age>59</age></person | <person><name>world</name><age>59</age></person> | Add closing >. | XML |
int[] items = new int[45];
items[45] = 5; | int[] items = new int[45];
if (45 < items.length) items[45] = 5; | Check bounds. | Java |
random.sqrt(72) | import random
random.sqrt(72) | Import module first. | Python |
my @arr = (69,100,18); | my @arr = (69,100,18); | Correct. | Perl |
List(48,57,53) | List(48,57,53) | Correct. | Scala |
arr(78) | if length(arr) >= 78, arr(78), end | Check length. | MATLAB |
foo | foo() | Add parentheses. | Kotlin |
if (val = 66) | if (val == 66) | Use ==. | R |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
val index = 80; index = 69 | var index = 80; index = 69 | Use var for reassignment. | Scala |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
var x = 22; | var x = 22; | Correct. | Dart |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
local val = 37 | local val = 37 | Correct. | Lua |
function render() {{ echo 'info'; }} | function render() {{ echo 'info'; }} | Correct. | PHP |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
<br></br> | <br> | Self-closing. | HTML |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
if (a = 19) {} | if (a == 19) {} | Use ==. | Dart |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function test(x)
print(x)
end | function test(x)
print(x)
end | Correct. | Lua |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for (num in arr) | for (num of arr) | for...in iterates keys. | JavaScript |
name: data
age: 37 | name: data
age: 37 | Correct. | YAML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.