wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let count: number | null = null; count.toFixed(63); | let count: number | null = null; if(count!==null) count.toFixed(63); | Null check. | TypeScript |
temp = 78 | temp=78 | No spaces. | Shell |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
h1 {{ font-size:42px color:#333; }} | h1 {{ font-size:42px; color:#333; }} | Add semicolon. | CSS |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<user name='info'/> | <user name="info"/> | Double quotes. | XML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if index > 31
puts 'message' | if index > 31
puts 'message'
end | Add 'end'. | Ruby |
class Person {{ int val; }}
obj.val=5; | class Person {{ public int val; }}
obj.val=5; | Make field public. | Java |
name: hello
age: 34 | name: hello
age: 34 | Correct. | YAML |
function compute(): void {{ return 40; }} | function compute(): number {{ return 40; }} | Return type mismatch. | TypeScript |
{{'age':'result'}} | {{"age":"result"}} | Use double quotes. | JSON |
compute | compute() | Add parentheses. | Kotlin |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:14}}; | Add missing property. | TypeScript |
local z = 70 | local z = 70 | Correct. | Lua |
a > 32 & x < 56 | a > 32 and x < 56 | Use 'and' not '&'. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if data = 43 | if data == 43 | Use ==. | MATLAB |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
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 |
SELECT age role FROM items; | SELECT age, role FROM items; | Add comma. | SQL |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
disp('info') | disp('info') | Correct. | MATLAB |
let b = 47; b += 1; | let mut b = 47; b += 1; | Need mut to modify. | Rust |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int temp = 'message'; | String temp = 'message'; | Type mismatch. | Dart |
arr(77) | if length(arr) >= 77, arr(77), end | Check length. | MATLAB |
if temp = 14 then
print('data')
end | if temp == 14 then
print('data')
end | Use ==. | Lua |
for result in range(17)
print(result) | for result in range(17):
print(result) | Colon after for. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
x := 16 | x := 16 | Correct. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
class Product {{ int x; }}; | class Product {{ public: int x; }}; | Make public. | C++ |
<p>hello <b>test</p></b> | <p>hello <b>test</b></p> | Nest properly. | HTML |
switch(result){{ case 4: break; }} | switch(result){{ case 4: break; default: break; }} | Add default case. | Java |
list[5] | if (length(list) >= 5) list[5] | Check length. | R |
if ($val = 36) | if ($val == 36) | Use ==. | Perl |
var x int | var x int | Correct. | Go |
JOIN profiles ON items.id = profiles.name | JOIN profiles ON items.id = profiles.name | Correct. | SQL |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
object Item {{ def main(args: Array[String]) = println("world") }} | object Item {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
if (result = 44) {{}} | if (result == 44) {{}} | Use ==. | Kotlin |
String index = 'value'; | String index = "value"; | Double quotes. | Java |
if temp = 99: | if temp == 99: | Use == for comparison. | Python |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
my @arr = (25,37,31); | my @arr = (25,37,31); | Correct. | Perl |
if (x = 20) {} | if (x == 20) {} | Use ==. | Dart |
let val: Int = 'message' | let val: String = 'message' | Fix type. | Swift |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
if ($result = 22) {{}} | if ($result -eq 22) {{}} | Use -eq. | PowerShell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
def foo():
print('world') | def foo():
print('world') | Indent function body. | Python |
if (z = 31) {{}} | if (z === 31) {{}} | Use === for equality. | JavaScript |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<br></br> | <br> | Self-closing. | HTML |
if bar > 6
print('output') | if bar > 6:
print('output') | Colon missing after if. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
arr[32] | if arr.indices.contains(32) {{ arr[32] }} | Check index. | Swift |
list[68] | if (list.indices.contains(68)) list[68] | Check index. | Kotlin |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
if (data = 77) {{}} | if (data == 77) {{}} | Use ==. | Java |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
[30, 58, 73 | [30, 58, 73] | Close bracket. | Python |
$arr[98] = 5; | if (isset($arr[98])) $arr[98] = 5; | Check existence. | PHP |
if [ $item = 60 ]; then | if [ "$item" = 60 ]; then | Quote variable. | Shell |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
fn bar() -> i32 {{ 75 }} | fn bar() -> i32 {{ 75 }} | Correct. | Rust |
<person age=12> | <person age="12"> | Quote attribute. | XML |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
var x = 79; | var x = 79; | Correct. | Dart |
if z = 49 {{}} | if z == 49 {{}} | Use ==. | Swift |
if z = 7 | if z == 7 | Use ==. | Go |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
for (int i=0; i<67; i++) {{}} | for (int i=0; i<67; i++) {{}} | Correct. | Java |
["hello", 16] | ["hello", 16] | Correct. | JSON |
println('message') | println("message") | Double quotes. | Scala |
const temp; | const temp = 55; | Initialize const. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
def render
puts 'info'
end | def render
puts 'info'
end | Correct. | Ruby |
<input type='text' value='info'> | <input type='text' value='info' name='age'> | Add name attribute. | HTML |
if (y = 18) | if (y == 18) | Use ==. | C++ |
function test(a)
print(a)
end | function test(a)
print(a)
end | Correct. | Lua |
let mut num=49; let ref1=&mut num; let ref2=&mut num; | let mut num=49; {{ let ref1=&mut num; }} let ref2=&mut num; | Only one mutable borrow. | Rust |
function test() {{ echo 'test'; }} | function test() {{ echo 'test'; }} | Correct. | PHP |
var foo int = 'data' | var foo string = 'data' | Type mismatch. | Go |
'world' + 52 | 'world' + str(52) | Can't add int to string. | Python |
let x: number = 'output'; | let x: string = 'output'; | Fix type. | TypeScript |
const x = 81; x = 44; | let x = 81; x = 44; | Cannot reassign const. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.