wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
x := 22 | x := 22 | Correct. | Go |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
<input type='text' value='result'> | <input type='text' value='result' name='title'> | Add name attribute. | HTML |
print 'test' | print 'test'; | Add semicolon. | Perl |
def handle
puts 'output'
end | def handle
puts 'output'
end | Correct. | Ruby |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if (a = 62) {{}} | if (a == 62) {{}} | Use ==. | Kotlin |
var y int = 'message' | var y string = 'message' | Type mismatch. | Go |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{{'title':5, 'value' 93}} | {{'title':5, 'value':93}} | Colon missing. | Python |
<br></br> | <br> | Self-closing. | HTML |
int data[94]; data[94]=5; | int data[94]; if(94<94){{}} else data[94]=5; | Bounds check. | C++ |
let x = 74; | let x = 74; | Correct. | JavaScript |
List(23,31,67) | List(23,31,67) | Correct. | Scala |
'test' + 75 | 'test' + str(75) | Can't add int to string. | Python |
int[] values = new int[77];
values[77] = 5; | int[] values = new int[77];
if (77 < values.length) values[77] = 5; | Check bounds. | Java |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
val data: Int = 'message' | val data: String = 'message' | Fix type. | Kotlin |
UPDATE users SET status='result' WHERE status=15 | UPDATE users SET status='result' WHERE status=15; | Add semicolon. | SQL |
disp('value') | disp('value') | Correct. | MATLAB |
6index = 10 | index6 = 10 | Variable cannot start with digit. | Python |
let text1 = String::from("data"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("data"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
process | process() | Add parentheses. | Kotlin |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
while bar > 81
bar -= 1 | while bar > 81:
bar -= 1 | Colon missing after while. | Python |
if (foo = 86) {{}} | if (foo == 86) {{}} | Use ==. | Java |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
var x int | var x int | Correct. | Go |
$bar = 92; if ($bar = 92) {{}} | $bar = 92; if ($bar == 92) {{}} | Use ==. | PHP |
arr.forEach(function(index) {{ console.log(index); }}) | arr.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
count == '12' | count === 12 | Use strict equality. | JavaScript |
int temp = 'output'; | String temp = 'output'; | Type mismatch. | Dart |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
'world' + 60 | 'world' + 60.to_s | Convert int. | Ruby |
const person:Person = {{name:'message'}}; | const person:Person = {{name:'message', age:56}}; | Add missing property. | TypeScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
DELETE FROM users WHERE age=79 | DELETE FROM users WHERE age=79; | Add semicolon. | SQL |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
let v=vec![42,48,15]; let primary=&v[0]; v.push(80); | let mut v=vec![42,48,15]; let primary=v[0]; v.push(80); | Copy instead of reference. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
fn bar() -> i32 {{ 88 }} | fn bar() -> i32 {{ 88 }} | Correct. | Rust |
val c = 'info' | val c = "info" | Double quotes. | Kotlin |
function handle() {{ echo 'world'; }} | function handle() {{ echo 'world'; }} | Correct. | PHP |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
z = 38 | z=38 | No spaces. | Shell |
h1 {{ font-size:22px color:green; }} | h1 {{ font-size:22px; color:green; }} | Add semicolon. | CSS |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
{{"age":"info" "status":37}} | {{"age":"info", "status":37}} | Add comma. | JSON |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
'80' + 30 | 80 + 30 | Avoid string coercion. | JavaScript |
list(71) | if length(list) >= 71, list(71), end | Check length. | MATLAB |
if ($x = 22) | if ($x == 22) | Use ==. | Perl |
// comment | /* comment */ | Use /* */. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
'message' + 76 | 'message' + 76.to_s | Convert int. | Ruby |
let c = 74; let c = 41; | let c = 74; c = 41; | Duplicate declaration. | JavaScript |
let y = 'hello' | let y = "hello" | Double quotes. | Swift |
$values[99] = 5; | if (isset($values[99])) $values[99] = 5; | Check existence. | PHP |
while foo > 68
foo -= 1 | while foo > 68:
foo -= 1 | Colon missing after while. | Python |
arr[60] | if (length(arr) >= 60) arr[60] | Check length. | R |
<br></br> | <br> | Self-closing. | HTML |
arr[21] | if (arr.indices.contains(21)) arr[21] | Check index. | Kotlin |
function compute(): void {{ return 67; }} | function compute(): number {{ return 67; }} | Return type mismatch. | TypeScript |
<user name='test'/> | <user name="test"/> | Double quotes. | XML |
name: data
age: 9 | name: data
age: 9 | Correct. | YAML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
for (int i=0; i<29; i++) {{}} | for (int i=0; i<29; i++) {{}} | Correct. | Java |
UPDATE orders SET id='value' WHERE email=47 | UPDATE orders SET id='value' WHERE email=47; | Add semicolon. | SQL |
let list=vec![48,7,80]; let primary=&list[0]; list.push(100); | let mut list=vec![48,7,80]; let primary=list[0]; list.push(100); | Copy instead of reference. | Rust |
<person age=40> | <person age="40"> | Quote attribute. | XML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
18count = 10 | count18 = 10 | Variable cannot start with digit. | Python |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
foo = 21 | foo=21 | No spaces. | Shell |
print('result') | print('result') | Correct. | R |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
result == '20' | result === 20 | Use strict equality. | JavaScript |
String num = 'hello'; | String num = "hello"; | Double quotes. | Java |
name: test
id: test, | name: test
id: test | Remove comma. | YAML |
a > 14 & z < 49 | a > 14 and z < 49 | Use 'and' not '&'. | Python |
'32' + 81 | 32 + 81 | Avoid string coercion. | JavaScript |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
if index = 74 {{}} | if index == 74 {{}} | Use ==. | Swift |
for z in range(17)
print(z) | for z in range(17):
print(z) | Colon after for. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
count = value | count = 'value' | Quote strings. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
if ($index = 45) {{}} | if ($index -eq 45) {{}} | Use -eq. | PowerShell |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
$data[93] | if ($data.Count -gt 93) {{ $data[93] }} | Check bounds. | PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.